blackburn

Drop-in serializer support for Express/Connect Node apps.

JSONAPISerializer Defined in lib/serializers/jsonapi.js

Renders the payload according to the JSONAPI 1.0 spec, including related resources, included records, and support for meta and links.

render (payloadoptions)

Take a payload (a model, an array of models, or an Error) and render it as a JSONAPI compliant document

Arguments

Returns

(Object)

the rendered JSONAPI document

renderPrimary (payloaddocumentoptions)

Render the primary payload for a JSONAPI document (either a model or array of models).

Arguments

renderIncluded (payloaddocumentoptions)

Render any included records into the top level of the document

Arguments

renderMeta (payloaddocumentoptions)

Render top level meta object for a document. Default uses meta supplied in options call to res.render().

Arguments

renderLinks (payloaddocumentoptions)

Render top level links object for a document. Defaults to the links supplied in options to res.render().

Arguments

renderVersion (payloaddocumentoptions)

Render the version of JSONAPI supported.

Arguments

renderRecord (optionsrecord)

Render the supplied record as a resource object.

Arguments

Returns

(Object)

a resource object representing the record

attributesForRecord (recordoptions)

Returns the JSONAPI attributes object representing this record's relationships

Arguments

Returns

(Object)

the JSONAPI attributes object

relationshipsForRecord (recordoptions)

Returns the JSONAPI relationships object representing this record's relationships

Arguments

Returns

(Object)

the JSONAPI relationships object

linksForRelationship (namedescriptorrecord)

Takes a relationship descriptor and the record it's for, and returns any links for that relationship for that record. I.e. '/books/1/author'

Arguments

Returns

(Object)

the links object for the supplied relationship

dataForRelationship (namedescriptorrecorddocumentoptions)

Takes a relationship descriptor and a record it's for, and returns the data for that relationship. Also sideloads any included records in the top level included namespace.

Arguments

Returns

(Array.<Object>)

array of resource identifiers

metaForRelationship (namedescriptorrecordoptions)

Returns any meta for a given relationship and record. No meta included by default.

Arguments

Returns

(Object)

linksForRecord (recordoptions)

Returns links for a particular record, i.e. self: "/books/1"

Arguments

Returns

(Object)

[description]

metaForRecord (recordoptions)

Returns meta for a particular record.

Arguments

Returns

(Object)

includeRecord (recorddescriptordocumentoptions)

Sideloads a record into the top level "included" array

Arguments

renderError (error)

Render the supplied error

Arguments

Returns

(Object)

the JSONAPI error object

sourceForError (error)

Given an error, return a JSON Pointer, a URL query param name, or other info indicating the source of the error.

Arguments

Returns

(Object)

an error source object, optionally including a "pointer" JSON Pointer or "parameter" for the query param that caused the error.

metaForError (error)

Return the meta for a given error object. You could use this for example, to return debug information in development environments.

Arguments

Returns

(Object)

linksForError (error)

Return a links object for an error. You could use this to link to a bug tracker report of the error, for example.

Arguments

Returns

(Object)

dedupeIncluded (document)

Remove duplicate entries from the sideloaded data.

Arguments