New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsonapi-server

Package Overview
Dependencies
Maintainers
3
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonapi-server - npm Package Compare versions

Comparing version 0.12.2 to 0.13.0

lib/mongoHandlers.js~

2

CHANGELOG.md

@@ -37,1 +37,3 @@ 2015-06-29 - Initial release

2015-11-11 - v0.12.2
2015-11-12 - Handlers readiness check
2015-11-12 - v0.13.0

21

documentation/handlers.md
### Creating Custom Handlers
Handlers represent the mechanism that backs a resource. Each handler is expected to provide some of the following functions:
* initialise - when jsonapi-server loads, this is invoked once for every resource using this handler. Its an opportunity to allocate memory, connect to databases, etc.
* search - for searching for resources that match some vague parameters.
* find - for finding a specific resource by id.
* create - for creating a new instance of a resource.
* delete - for deleting an existing resource.
* update - for updating an existing resource.
Handlers represent the mechanism that backs a resource. Each handler is expected to provide:
* a `ready` property indicating the handler is ready to process requests.
* some of the following functions:
* `initialise` - when jsonapi-server loads, this is invoked once for every resource using this handler. Its an opportunity to allocate memory, connect to databases, etc.
* `search` - for searching for resources that match some vague parameters.
* `find` - for finding a specific resource by id.
* `create` - for creating a new instance of a resource.
* `delete` - for deleting an existing resource.
* `update` - for updating an existing resource.
Failure to provide the above handler functions will result in `EFORBIDDEN` HTTP errors if the corresponding REST routes are requested.

@@ -67,2 +70,6 @@

#### ready
The `ready` property should be set to a _truthy_ value once the handler is ready to process requests (which will usually happen at the end of `initialise`). If the handler is temporarily unable to process requests this property should be set to a _falsy_ value during the down period.
#### initialise

@@ -69,0 +76,0 @@ `initialise` is invoked with the `resourceConfig` of each resource using this handler.

@@ -10,2 +10,7 @@ "use strict";

/**
Handlers readiness status. This should be set to `true` once all handlers are ready to process requests.
*/
memoryStore.handlers.ready = false;
/**
initialise gets invoked once for each resource that uses this hander.

@@ -16,2 +21,3 @@ In this instance, we're allocating an array in our in-memory data store.

resources[resourceConfig.resource] = resourceConfig.examples || [ ];
memoryStore.handlers.ready = true;
};

@@ -18,0 +24,0 @@

@@ -51,2 +51,11 @@ "use strict";

if (!resourceConfig.handlers.ready) {
return helper.handleError(request, res, {
status: "503",
code: "EUNAVAILABLE",
title: "Resource temporarily unavailable",
detail: "The requested resource '" + request.params.type + "' is temporarily unavailable"
});
}
if (!resourceConfig.handlers[handlerRequest]) {

@@ -53,0 +62,0 @@ return helper.handleError(request, res, {

{
"name": "jsonapi-server",
"version": "0.12.2",
"version": "0.13.0",
"description": "A fully featured NodeJS sever implementation of json:api. You provide the resources, we provide the api.",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc