json-rest-api 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/audit/00-charter.md +103 -0
- package/audit/01-scope-map.md +84 -0
- package/audit/02-coverage-matrix.csv +174 -0
- package/audit/03-invariants.md +123 -0
- package/audit/04-standards-rubric.md +56 -0
- package/audit/05-competitor-rubric.md +77 -0
- package/audit/06-findings.md +160 -0
- package/audit/07-risk-register.csv +10 -0
- package/audit/08-remediation-roadmap.md +177 -0
- package/audit/09-signoff-check.md +23 -0
- package/audit/10-final-synthesis.md +29 -0
- package/audit/evidence/code/all-files-json-rest-api.txt +168 -0
- package/audit/evidence/code/all-files-json-rest-schema.txt +12 -0
- package/audit/evidence/code/boundary-leak-checks.txt +72 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__bulk-operations-plugin.js.txt +480 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__express-plugin.js.txt +532 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__lib__busboy-detector.js.txt +175 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__lib__formidable-detector.js.txt +138 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__lib__request-helpers.js.txt +222 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__file-handling-plugin.js.txt +342 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__dbTablesOperations.js.txt +304 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__fractional-positioning.js.txt +188 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__compile-schemas.js.txt +336 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__connectors-query-parser.js.txt +165 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__database-capabilities.js.txt +265 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__database-value-normalizers.js.txt +369 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__default-data-helpers.js.txt +72 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__field-utils.js.txt +139 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__knex-constants.js.txt +45 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__knex-field-helpers.js.txt +396 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__knex-json-api-transformers.js.txt +162 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__payload-validators.js.txt +1314 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__schema-helpers.js.txt +488 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__scope-validations.js.txt +484 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__simplified-helpers.js.txt +857 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-cross-table-search.js.txt +565 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-json-api-transformers-querying.js.txt +485 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-pagination-helpers.js.txt +560 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-process-includes.js.txt +167 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-query-helpers-base.js.txt +109 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-query-helpers.js.txt +1064 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-relationship-includes.js.txt +1983 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-window-queries.js.txt +328 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__url-helpers.js.txt +119 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__storage__storage-adapter.js.txt +160 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__writing__many-to-many-manipulations.js.txt +300 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__writing__relationship-processor.js.txt +245 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-access.js.txt +459 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-cors-plugin.js.txt +237 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-knex-plugin.js.txt +1135 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-multihome-plugin.js.txt +314 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__compile-resource-schemas.js.txt +7 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__register-relationship-routes.js.txt +71 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__register-scope-routes.js.txt +102 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__turn-scope-init-into-vars.js.txt +49 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__validate-include-configurations.js.txt +39 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__add-route.js.txt +23 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__check-permissions.js.txt +13 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__common.js.txt +639 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__delete-relationship.js.txt +117 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__delete.js.txt +104 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__enrich-attributes.js.txt +199 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__get-related.js.txt +353 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__get-relationship.js.txt +61 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__get.js.txt +184 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__patch-relationship.js.txt +55 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__patch.js.txt +191 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__post-relationship.js.txt +110 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__post.js.txt +168 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__put.js.txt +253 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__query.js.txt +207 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__release.js.txt +12 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin.js.txt +165 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-positioning-plugin.js.txt +668 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__socketio-plugin.js.txt +621 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__storage__local-storage.js.txt +218 -0
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__storage__s3-storage.js.txt +124 -0
- package/audit/evidence/code/critical-pass1/json-rest-schema__src__CorePlugin.js.txt +269 -0
- package/audit/evidence/code/critical-pass1/json-rest-schema__src__Schema.js.txt +242 -0
- package/audit/evidence/code/critical-pass1/json-rest-schema__src__index.js.txt +77 -0
- package/audit/evidence/code/critical-pass1-risk-keywords.txt +238 -0
- package/audit/evidence/code/critical-pass1-summary.csv +67 -0
- package/audit/evidence/code/critical-pass2-summary.csv +67 -0
- package/audit/evidence/code/early-silent-zones-no-test-token.txt +57 -0
- package/audit/evidence/code/error-model-signals.txt +98 -0
- package/audit/evidence/code/git-files-json-rest-api.txt +171 -0
- package/audit/evidence/code/git-files-json-rest-schema.txt +27 -0
- package/audit/evidence/code/hook-flow-signals.txt +282 -0
- package/audit/evidence/code/idproperty-signals.txt +157 -0
- package/audit/evidence/code/import-cycles-non-anyapi.txt +3 -0
- package/audit/evidence/code/import-hotspots-non-anyapi.txt +96 -0
- package/audit/evidence/code/imports-json-rest-api.txt +354 -0
- package/audit/evidence/code/imports-json-rest-schema.txt +15 -0
- package/audit/evidence/code/in-scope-files-json-rest-api.txt +160 -0
- package/audit/evidence/code/in-scope-files-json-rest-schema.txt +13 -0
- package/audit/evidence/code/non-anyapi-core-files.txt +101 -0
- package/audit/evidence/code/permission-signals.txt +193 -0
- package/audit/evidence/code/query-include-signals.txt +687 -0
- package/audit/evidence/code/transaction-signals.txt +28 -0
- package/audit/evidence/code/validation-signals.txt +650 -0
- package/audit/evidence/code/write-path-signals.txt +61 -0
- package/audit/evidence/docs/docs-claims-signals.txt +1075 -0
- package/audit/evidence/docs/schema-docs-claims-signals.txt +179 -0
- package/audit/evidence/external/corpus-freeze.md +21 -0
- package/audit/evidence/external/npm-competitor-metadata.txt +70 -0
- package/audit/evidence/external/npm-download-signals.txt +23 -0
- package/audit/evidence/external/npm-jsonapi-server.txt +8 -0
- package/audit/evidence/external/npm-modern-jsonapi-metadata.txt +38 -0
- package/audit/evidence/external/readme-fortune-signals.txt +26 -0
- package/audit/evidence/external/readme-fortune.md +165 -0
- package/audit/evidence/external/readme-json-api-serializer-signals.txt +80 -0
- package/audit/evidence/external/readme-json-api-serializer.md +690 -0
- package/audit/evidence/external/readme-jsonapi-serde-server-signals.txt +0 -0
- package/audit/evidence/external/readme-jsonapi-serde-server.md +22 -0
- package/audit/evidence/external/readme-jsonapi-serializer-signals.txt +63 -0
- package/audit/evidence/external/readme-jsonapi-serializer.md +315 -0
- package/audit/evidence/external/readme-jsonapi-server-signals.txt +19 -0
- package/audit/evidence/external/readme-jsonapi-server.md +104 -0
- package/audit/evidence/external/readme-nestjs-json-api-signals.txt +4 -0
- package/audit/evidence/external/readme-nestjs-json-api.md +94 -0
- package/audit/evidence/external/readme-yaser-json-api-nestjs-signals.txt +47 -0
- package/audit/evidence/external/readme-yaser-json-api-nestjs.md +447 -0
- package/audit/evidence/external/standard-jsonapi-snippets.txt +84 -0
- package/audit/evidence/external/standard-rfc-snippets.txt +168 -0
- package/audit/evidence/external/standards-sources.txt +6 -0
- package/audit/evidence/runtime/baseline-commits.txt +2 -0
- package/audit/evidence/runtime/db-adapter-assumptions.txt +3 -0
- package/audit/evidence/runtime/environment.txt +4 -0
- package/audit/evidence/runtime/invariant-runtime-mapping.md +38 -0
- package/audit/evidence/runtime/probe-patch-relationship-error.exitcode +1 -0
- package/audit/evidence/runtime/probe-patch-relationship-error.log +76 -0
- package/audit/evidence/runtime/probe-patch-relationship-error.mjs +67 -0
- package/audit/evidence/runtime/probe-patch-relationship-referenceerror.exitcode +1 -0
- package/audit/evidence/runtime/probe-patch-relationship-referenceerror.log +62 -0
- package/audit/evidence/runtime/probe-patch-relationship-referenceerror.mjs +47 -0
- package/audit/evidence/runtime/test-exitcodes.txt +4 -0
- package/audit/evidence/runtime/test-summary.md +107 -0
- package/audit/evidence/runtime/trace-anchors.txt +61 -0
- package/audit/evidence/tests/access-multitenancy-test-signals.txt +125 -0
- package/audit/evidence/tests/failing-tests-summary.txt +25 -0
- package/audit/evidence/tests/npm-test-json-rest-api.exitcode +1 -0
- package/audit/evidence/tests/npm-test-json-rest-api.log +5885 -0
- package/audit/evidence/tests/npm-test-json-rest-schema.exitcode +1 -0
- package/audit/evidence/tests/npm-test-json-rest-schema.log +356 -0
- package/audit/evidence/tests/query-include-test-signals.txt +948 -0
- package/audit/evidence/tests/relationship-test-signals.txt +223 -0
- package/audit/evidence/tests/skipped-tests.txt +10 -0
- package/audit/evidence/tests/test-suite-list-non-anyapi.txt +30 -0
- package/audit/evidence/tests/test-suite-list.txt +32 -0
- package/audit/subsystems/docs-drift.md +49 -0
- package/audit/subsystems/pass2-cross-review.md +131 -0
- package/audit/subsystems/plugins-access.md +51 -0
- package/audit/subsystems/plugins-bulk.md +50 -0
- package/audit/subsystems/plugins-cors.md +48 -0
- package/audit/subsystems/plugins-file.md +53 -0
- package/audit/subsystems/plugins-multihome.md +50 -0
- package/audit/subsystems/plugins-positioning.md +54 -0
- package/audit/subsystems/plugins-socketio.md +50 -0
- package/audit/subsystems/query-engine.md +61 -0
- package/audit/subsystems/relationships.md +55 -0
- package/audit/subsystems/rest-orchestration.md +66 -0
- package/audit/subsystems/schema-core.md +64 -0
- package/audit/subsystems/storage-knex.md +57 -0
- package/audit/subsystems/tests.md +48 -0
- package/audit/subsystems/transport-express.md +55 -0
- package/audit/traces/trace-read-get.md +22 -0
- package/audit/traces/trace-read-query.md +25 -0
- package/audit/traces/trace-relationship-endpoints.md +31 -0
- package/audit/traces/trace-write-delete.md +17 -0
- package/audit/traces/trace-write-patch.md +26 -0
- package/audit/traces/trace-write-post.md +22 -0
- package/audit/traces/trace-write-put.md +23 -0
- package/package.json +3 -3
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
# json-api-serializer
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/danivek/json-api-serializer)
|
|
4
|
+
[](https://coveralls.io/github/danivek/json-api-serializer?branch=master)
|
|
5
|
+
[](https://www.npmjs.org/package/json-api-serializer)
|
|
6
|
+
|
|
7
|
+
A Node.js/browser framework agnostic library for serializing your data to [JSON API](http://jsonapi.org/) compliant responses (a specification for building APIs in JSON).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install --save json-api-serializer
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Documentation
|
|
16
|
+
|
|
17
|
+
### Register
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
var JSONAPISerializer = require("json-api-serializer");
|
|
21
|
+
var Serializer = new JSONAPISerializer();
|
|
22
|
+
Serializer.register(type, options);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Serialization options:**
|
|
26
|
+
|
|
27
|
+
* **id** (optional): The key to use as the reference. Default = 'id'.
|
|
28
|
+
* **blacklist** (optional): An array of blacklisted attributes. Default = [].
|
|
29
|
+
* **whitelist** (optional): An array of whitelisted attributes. Default = [].
|
|
30
|
+
* **jsonapiObject** (optional): Enable/Disable [JSON API Object](http://jsonapi.org/format/#document-jsonapi-object). Default = true.
|
|
31
|
+
* **links** (optional): Describes the links inside data. It can be:
|
|
32
|
+
* An _object_ (values can be string or function).
|
|
33
|
+
* A _function_ with one argument `function(data) { ... }` or with two arguments `function(data, extraData) { ... }`
|
|
34
|
+
* **topLevelMeta** (optional): Describes the top-level meta. It can be:
|
|
35
|
+
* An _object_ (values can be string or function).
|
|
36
|
+
* A _function_ with one argument `function(extraData) { ... }` or with two arguments `function(data, extraData) { ... }`
|
|
37
|
+
* **topLevelLinks** (optional): Describes the top-level links. It can be:
|
|
38
|
+
* An _object_ (values can be string or function).
|
|
39
|
+
* A _function_ with one argument `function(extraData) { ... }` or with two arguments `function(data, extraData) { ... }`
|
|
40
|
+
* **meta** (optional): Describes resource-level meta. It can be:
|
|
41
|
+
* An _object_ (values can be string or function).
|
|
42
|
+
* A _function_ with one argument `function(data) { ... }` or with two arguments `function(data, extraData) { ... }`
|
|
43
|
+
* **relationships** (optional): An object defining some relationships
|
|
44
|
+
* relationship: The property in data to use as a relationship
|
|
45
|
+
* **type**: A _string_ or a _function_ `function(relationshipData, data) { ... }` for the type to use for serializing the relationship (type need to be register).
|
|
46
|
+
* **alternativeKey** (optional): An alternative key (string or path) to use if relationship key not exist (example: 'author_id' as an alternative key for 'author' relationship). See [issue #12](https://github.com/danivek/json-api-serializer/issues/12).
|
|
47
|
+
* **schema** (optional): A custom schema for serializing the relationship. If no schema define, it use the default one.
|
|
48
|
+
* **links** (optional): Describes the links for the relationship. It can be:
|
|
49
|
+
* An _object_ (values can be string or function).
|
|
50
|
+
* A _function_ with one argument `function(data) { ... }` or with two arguments `function(data, extraData) { ... }`
|
|
51
|
+
* **meta** (optional): Describes meta that contains non-standard meta-information about the relationship. It can be:
|
|
52
|
+
* An _object_ (values can be string or function).
|
|
53
|
+
* A _function_ with one argument `function(data) { ... }` or with two arguments `function(data, extraData) { ... }`
|
|
54
|
+
* **deserialize** (optional): Describes the function which should be used to deserialize a related property which is not included in the JSON:API document. It should be:
|
|
55
|
+
* A _function_ with one argument `function(data) { ... }`which defines the format to which a relation should be deserialized. By default, the ID of the related object is returned, which would be equal to `function(data) {return data.id}`. See [issue #65](https://github.com/danivek/json-api-serializer/issues/65).
|
|
56
|
+
* **convertCase** (optional): Case conversion for serializing data. Value can be : `kebab-case`, `snake_case`, `camelCase`
|
|
57
|
+
* **beforeSerialize** (optional): A _function_ with one argument `beforeSerialize(data) => newData` to transform data before serialization.
|
|
58
|
+
|
|
59
|
+
**Deserialization options:**
|
|
60
|
+
|
|
61
|
+
* **unconvertCase** (optional): Case conversion for deserializing data. Value can be : `kebab-case`, `snake_case`, `camelCase`
|
|
62
|
+
* **blacklistOnDeserialize** (optional): An array of blacklisted attributes. Default = [].
|
|
63
|
+
* **whitelistOnDeserialize** (optional): An array of whitelisted attributes. Default = [].
|
|
64
|
+
* **afterDeserialize** (optional): A _function_ with one argument `afterDeserialize(data) => newData` to transform data after deserialization.
|
|
65
|
+
|
|
66
|
+
**Global options:**
|
|
67
|
+
|
|
68
|
+
To avoid repeating the same options for each type, it's possible to add global options on `JSONAPISerializer` instance:
|
|
69
|
+
|
|
70
|
+
When using convertCase, a LRU cache is utilized for optimization. The default size of the cache is 5000 per conversion type. The size of the cache can be set with the `convertCaseCacheSize` option. Passing in 0 will result in a LRU cache of infinite size.
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
var JSONAPISerializer = require("json-api-serializer");
|
|
74
|
+
var Serializer = new JSONAPISerializer({
|
|
75
|
+
convertCase: "kebab-case",
|
|
76
|
+
unconvertCase: "camelCase",
|
|
77
|
+
convertCaseCacheSize: 0
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
input data (can be an object or an array of objects)
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
// Data
|
|
87
|
+
var data = [
|
|
88
|
+
{
|
|
89
|
+
id: "1",
|
|
90
|
+
title: "JSON API paints my bikeshed!",
|
|
91
|
+
body: "The shortest article. Ever.",
|
|
92
|
+
created: "2015-05-22T14:56:29.000Z",
|
|
93
|
+
updated: "2015-05-22T14:56:28.000Z",
|
|
94
|
+
author: {
|
|
95
|
+
id: "1",
|
|
96
|
+
firstName: "Kaley",
|
|
97
|
+
lastName: "Maggio",
|
|
98
|
+
email: "Kaley-Maggio@example.com",
|
|
99
|
+
age: "80",
|
|
100
|
+
gender: "male"
|
|
101
|
+
},
|
|
102
|
+
tags: ["1", "2"],
|
|
103
|
+
photos: [
|
|
104
|
+
"***",
|
|
105
|
+
"***",
|
|
106
|
+
"***"
|
|
107
|
+
],
|
|
108
|
+
comments: [
|
|
109
|
+
{
|
|
110
|
+
_id: "1",
|
|
111
|
+
body: "First !",
|
|
112
|
+
created: "2015-08-14T18:42:16.475Z"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
_id: "2",
|
|
116
|
+
body: "I Like !",
|
|
117
|
+
created: "2015-09-14T18:42:12.475Z"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
_id: "3",
|
|
121
|
+
body: "Awesome",
|
|
122
|
+
created: "2015-09-15T18:42:12.475Z"
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
];
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Register
|
|
130
|
+
|
|
131
|
+
Register your resources types :
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
var JSONAPISerializer = require("json-api-serializer");
|
|
135
|
+
var Serializer = new JSONAPISerializer();
|
|
136
|
+
|
|
137
|
+
// Register 'article' type
|
|
138
|
+
Serializer.register("article", {
|
|
139
|
+
id: "id", // The attributes to use as the reference. Default = 'id'.
|
|
140
|
+
blacklist: ["updated"], // An array of blacklisted attributes. Default = []
|
|
141
|
+
links: {
|
|
142
|
+
// An object or a function that describes links.
|
|
143
|
+
self: function(data) {
|
|
144
|
+
// Can be a function or a string value ex: { self: '/articles/1'}
|
|
145
|
+
return "/articles/" + data.id;
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
relationships: {
|
|
149
|
+
// An object defining some relationships.
|
|
150
|
+
author: {
|
|
151
|
+
type: "people", // The type of the resource
|
|
152
|
+
links: function(data) {
|
|
153
|
+
// An object or a function that describes Relationships links
|
|
154
|
+
return {
|
|
155
|
+
self: "/articles/" + data.id + "/relationships/author",
|
|
156
|
+
related: "/articles/" + data.id + "/author"
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
tags: {
|
|
161
|
+
type: "tag"
|
|
162
|
+
},
|
|
163
|
+
photos: {
|
|
164
|
+
type: "photo"
|
|
165
|
+
},
|
|
166
|
+
comments: {
|
|
167
|
+
type: "comment",
|
|
168
|
+
schema: "only-body" // A custom schema
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
topLevelMeta: function(data, extraData) {
|
|
172
|
+
// An object or a function that describes top level meta.
|
|
173
|
+
return {
|
|
174
|
+
count: extraData.count,
|
|
175
|
+
total: data.length
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
topLevelLinks: {
|
|
179
|
+
// An object or a function that describes top level links.
|
|
180
|
+
self: "/articles" // Can be a function (with extra data argument) or a string value
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Register 'people' type
|
|
185
|
+
Serializer.register("people", {
|
|
186
|
+
id: "id",
|
|
187
|
+
links: {
|
|
188
|
+
self: function(data) {
|
|
189
|
+
return "/peoples/" + data.id;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Register 'tag' type
|
|
195
|
+
Serializer.register("tag", {
|
|
196
|
+
id: "id"
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Register 'photo' type
|
|
200
|
+
Serializer.register("photo", {
|
|
201
|
+
id: "id"
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Register 'comment' type with a custom schema
|
|
205
|
+
Serializer.register("comment", "only-body", {
|
|
206
|
+
id: "_id"
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Serialize
|
|
211
|
+
|
|
212
|
+
Serialize it with the corresponding resource type, data and optional extra data :
|
|
213
|
+
|
|
214
|
+
```javascript
|
|
215
|
+
// Synchronously (blocking)
|
|
216
|
+
const result = Serializer.serialize('article', data, {count: 2});
|
|
217
|
+
|
|
218
|
+
// Asynchronously (non-blocking)
|
|
219
|
+
Serializer.serializeAsync('article', data, {count: 2})
|
|
220
|
+
.then((result) => {
|
|
221
|
+
...
|
|
222
|
+
});
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
The output data will be :
|
|
226
|
+
|
|
227
|
+
```JSON
|
|
228
|
+
{
|
|
229
|
+
"jsonapi": {
|
|
230
|
+
"version": "1.0"
|
|
231
|
+
},
|
|
232
|
+
"meta": {
|
|
233
|
+
"count": 2,
|
|
234
|
+
"total": 1
|
|
235
|
+
},
|
|
236
|
+
"links": {
|
|
237
|
+
"self": "/articles"
|
|
238
|
+
},
|
|
239
|
+
"data": [{
|
|
240
|
+
"type": "article",
|
|
241
|
+
"id": "1",
|
|
242
|
+
"attributes": {
|
|
243
|
+
"title": "JSON API paints my bikeshed!",
|
|
244
|
+
"body": "The shortest article. Ever.",
|
|
245
|
+
"created": "2015-05-22T14:56:29.000Z"
|
|
246
|
+
},
|
|
247
|
+
"relationships": {
|
|
248
|
+
"author": {
|
|
249
|
+
"data": {
|
|
250
|
+
"type": "people",
|
|
251
|
+
"id": "1"
|
|
252
|
+
},
|
|
253
|
+
"links": {
|
|
254
|
+
"self": "/articles/1/relationships/author",
|
|
255
|
+
"related": "/articles/1/author"
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
"tags": {
|
|
259
|
+
"data": [{
|
|
260
|
+
"type": "tag",
|
|
261
|
+
"id": "1"
|
|
262
|
+
}, {
|
|
263
|
+
"type": "tag",
|
|
264
|
+
"id": "2"
|
|
265
|
+
}]
|
|
266
|
+
},
|
|
267
|
+
"photos": {
|
|
268
|
+
"data": [{
|
|
269
|
+
"type": "photo",
|
|
270
|
+
"id": "***"
|
|
271
|
+
}, {
|
|
272
|
+
"type": "photo",
|
|
273
|
+
"id": "***"
|
|
274
|
+
}, {
|
|
275
|
+
"type": "photo",
|
|
276
|
+
"id": "***"
|
|
277
|
+
}]
|
|
278
|
+
},
|
|
279
|
+
"comments": {
|
|
280
|
+
"data": [{
|
|
281
|
+
"type": "comment",
|
|
282
|
+
"id": "1"
|
|
283
|
+
}, {
|
|
284
|
+
"type": "comment",
|
|
285
|
+
"id": "2"
|
|
286
|
+
}, {
|
|
287
|
+
"type": "comment",
|
|
288
|
+
"id": "3"
|
|
289
|
+
}]
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
"links": {
|
|
293
|
+
"self": "/articles/1"
|
|
294
|
+
}
|
|
295
|
+
}],
|
|
296
|
+
"included": [{
|
|
297
|
+
"type": "people",
|
|
298
|
+
"id": "1",
|
|
299
|
+
"attributes": {
|
|
300
|
+
"firstName": "Kaley",
|
|
301
|
+
"lastName": "Maggio",
|
|
302
|
+
"email": "Kaley-Maggio@example.com",
|
|
303
|
+
"age": "80",
|
|
304
|
+
"gender": "male"
|
|
305
|
+
},
|
|
306
|
+
"links": {
|
|
307
|
+
"self": "/peoples/1"
|
|
308
|
+
}
|
|
309
|
+
}, {
|
|
310
|
+
"type": "comment",
|
|
311
|
+
"id": "1",
|
|
312
|
+
"attributes": {
|
|
313
|
+
"body": "First !"
|
|
314
|
+
}
|
|
315
|
+
}, {
|
|
316
|
+
"type": "comment",
|
|
317
|
+
"id": "2",
|
|
318
|
+
"attributes": {
|
|
319
|
+
"body": "I Like !"
|
|
320
|
+
}
|
|
321
|
+
}, {
|
|
322
|
+
"type": "comment",
|
|
323
|
+
"id": "3",
|
|
324
|
+
"attributes": {
|
|
325
|
+
"body": "Awesome"
|
|
326
|
+
}
|
|
327
|
+
}]
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
There is an available argument `excludeData` that will exclude the `data`
|
|
332
|
+
property from the serialized object. This can be used in cases where you may
|
|
333
|
+
want to only include the `topLevelMeta` in your response, such as a `DELETE`
|
|
334
|
+
response with only a `meta` property, or other cases defined in the
|
|
335
|
+
JSON:API spec.
|
|
336
|
+
|
|
337
|
+
```javascript
|
|
338
|
+
// Synchronously (blocking)
|
|
339
|
+
const result = Serializer.serialize('article', data, 'default', {count: 2}, true);
|
|
340
|
+
|
|
341
|
+
// Asynchronously (non-blocking)
|
|
342
|
+
Serializer.serializeAsync('article', data, 'default', {count: 2}, true)
|
|
343
|
+
.then((result) => {
|
|
344
|
+
...
|
|
345
|
+
});
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
#### Override schema options
|
|
349
|
+
|
|
350
|
+
On each individual call to `serialize` or `serializeAsync`, there is an parameter to override the options of any registered type. For example on a call to serialize, if a whitelist was not defined on the registered schema options, a whitelist (or any other options) for that type can be provided. This parameter is an object, where the key are the registered type names, and the values are the objects to override the registered schema.
|
|
351
|
+
|
|
352
|
+
In the following example, only the attribute `name` will be serialized on the article, and if there is a relationship for `person`, it will be serialized with `camelCase` even if the registered schema has a different value.
|
|
353
|
+
```
|
|
354
|
+
const result = Serializer.serialize('article', data, 'default', {count: 2}, true), {
|
|
355
|
+
article: {
|
|
356
|
+
whitelist: ['name']
|
|
357
|
+
},
|
|
358
|
+
person: {
|
|
359
|
+
convertCase: 'camelCase'
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
Some others examples are available in [tests folders](https://github.com/danivek/json-api-serializer/blob/master/test/)
|
|
366
|
+
|
|
367
|
+
### Deserialize
|
|
368
|
+
|
|
369
|
+
input data (can be an simple object or an array of objects)
|
|
370
|
+
|
|
371
|
+
```javascript
|
|
372
|
+
var data = {
|
|
373
|
+
data: {
|
|
374
|
+
type: 'article',
|
|
375
|
+
id: '1',
|
|
376
|
+
attributes: {
|
|
377
|
+
title: 'JSON API paints my bikeshed!',
|
|
378
|
+
body: 'The shortest article. Ever.',
|
|
379
|
+
created: '2015-05-22T14:56:29.000Z'
|
|
380
|
+
},
|
|
381
|
+
relationships: {
|
|
382
|
+
author: {
|
|
383
|
+
data: {
|
|
384
|
+
type: 'people',
|
|
385
|
+
id: '1'
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
comments: {
|
|
389
|
+
data: [{
|
|
390
|
+
type: 'comment',
|
|
391
|
+
id: '1'
|
|
392
|
+
}, {
|
|
393
|
+
type: 'comment',
|
|
394
|
+
id: '2'
|
|
395
|
+
}]
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// Synchronously (blocking)
|
|
402
|
+
Serializer.deserialize('article', data);
|
|
403
|
+
|
|
404
|
+
// Asynchronously (non-blocking)
|
|
405
|
+
Serializer.deserializeAsync('article', data)
|
|
406
|
+
.then((result) => {
|
|
407
|
+
// ...
|
|
408
|
+
});
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
```JSON
|
|
412
|
+
{
|
|
413
|
+
"id": "1",
|
|
414
|
+
"title": "JSON API paints my bikeshed!",
|
|
415
|
+
"body": "The shortest article. Ever.",
|
|
416
|
+
"created": "2015-05-22T14:56:29.000Z",
|
|
417
|
+
"author": "1",
|
|
418
|
+
"comments": [
|
|
419
|
+
"1",
|
|
420
|
+
"2"
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### serializeError
|
|
426
|
+
|
|
427
|
+
Serializes any error into a JSON API error document.
|
|
428
|
+
|
|
429
|
+
Input data can be:
|
|
430
|
+
- An instance of `Error` or an array of `Error` instances.
|
|
431
|
+
- A [JSON API error object](http://jsonapi.org/format/#error-objects) or an array of [JSON API error objects](http://jsonapi.org/format/#error-objects).
|
|
432
|
+
|
|
433
|
+
Using an instance of `Error`:
|
|
434
|
+
|
|
435
|
+
```javascript
|
|
436
|
+
const error = new Error('An error occurred');
|
|
437
|
+
error.id = 123
|
|
438
|
+
error.links = { about: 'https://example.com/errors/123' }
|
|
439
|
+
error.status = 500; // or `statusCode`
|
|
440
|
+
error.code = 'xyz'
|
|
441
|
+
error.meta = { time: Date.now() }
|
|
442
|
+
|
|
443
|
+
Serializer.serializeError(error);
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
The result will be:
|
|
447
|
+
|
|
448
|
+
```JSON
|
|
449
|
+
{
|
|
450
|
+
"errors": [
|
|
451
|
+
{
|
|
452
|
+
"id": 123,
|
|
453
|
+
"links": {
|
|
454
|
+
"about": "https://example.com/errors/123"
|
|
455
|
+
},
|
|
456
|
+
"status": "500",
|
|
457
|
+
"code": "xyz",
|
|
458
|
+
"title": "Error",
|
|
459
|
+
"detail": "An error occurred",
|
|
460
|
+
"meta": {
|
|
461
|
+
"time": 1593561258853
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
]
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
Using an instance of a class that inherits from `Error`:
|
|
469
|
+
|
|
470
|
+
```js
|
|
471
|
+
class MyCustomError extends Error {
|
|
472
|
+
constructor(message = 'Something went wrong') {
|
|
473
|
+
super(message)
|
|
474
|
+
this.id = 123
|
|
475
|
+
this.links = {
|
|
476
|
+
about: 'https://example.com/errors/123'
|
|
477
|
+
}
|
|
478
|
+
this.status = 500 // or `statusCode`
|
|
479
|
+
this.code = 'xyz'
|
|
480
|
+
this.meta = {
|
|
481
|
+
time: Date.now()
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
Serializer.serializeError(new MyCustomError());
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
The result will be:
|
|
490
|
+
|
|
491
|
+
```JSON
|
|
492
|
+
{
|
|
493
|
+
"errors": [
|
|
494
|
+
{
|
|
495
|
+
"id": 123,
|
|
496
|
+
"links": {
|
|
497
|
+
"about": "https://example.com/errors/123"
|
|
498
|
+
},
|
|
499
|
+
"status": "500",
|
|
500
|
+
"code": "xyz",
|
|
501
|
+
"title": "MyCustomError",
|
|
502
|
+
"detail": "Something went wrong",
|
|
503
|
+
"meta": {
|
|
504
|
+
"time": 1593561258853
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
]
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
Using a POJO:
|
|
512
|
+
|
|
513
|
+
```js
|
|
514
|
+
Serializer.serializeError({
|
|
515
|
+
id: 123,
|
|
516
|
+
links: {
|
|
517
|
+
about: 'https://example.com/errors/123'
|
|
518
|
+
},
|
|
519
|
+
status: 500, // or `statusCode`
|
|
520
|
+
code: 'xyz',
|
|
521
|
+
title: 'UserNotFound',
|
|
522
|
+
detail: 'Unable to find a user with the provided ID',
|
|
523
|
+
meta: {
|
|
524
|
+
time: Date.now()
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
The result will be:
|
|
530
|
+
|
|
531
|
+
```JSON
|
|
532
|
+
{
|
|
533
|
+
"errors": [
|
|
534
|
+
{
|
|
535
|
+
"id": 123,
|
|
536
|
+
"links": {
|
|
537
|
+
"about": "https://example.com/errors/123"
|
|
538
|
+
},
|
|
539
|
+
"status": "500",
|
|
540
|
+
"code": "xyz",
|
|
541
|
+
"title": "UserNotFound",
|
|
542
|
+
"detail": "Unable to find a user with the provided ID",
|
|
543
|
+
"meta": {
|
|
544
|
+
"time": 1593561258853
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
]
|
|
548
|
+
}
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
## Custom schemas
|
|
552
|
+
|
|
553
|
+
It is possible to define multiple custom schemas for a resource type :
|
|
554
|
+
|
|
555
|
+
```javascript
|
|
556
|
+
Serializer.register(type, "customSchema", options);
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
Then you can apply this schema on the primary data when serialize or deserialize :
|
|
560
|
+
|
|
561
|
+
```javascript
|
|
562
|
+
Serializer.serialize("article", data, "customSchema", { count: 2 });
|
|
563
|
+
Serializer.serializeAsync("article", data, "customSchema", { count: 2 });
|
|
564
|
+
Serializer.deserialize("article", jsonapiData, "customSchema");
|
|
565
|
+
Serializer.deserializeAsync("article", jsonapiData, "customSchema");
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
Or if you want to apply this schema on a relationship data, define this schema on relationships options with the key `schema` :
|
|
569
|
+
|
|
570
|
+
Example :
|
|
571
|
+
|
|
572
|
+
```javascript
|
|
573
|
+
relationships: {
|
|
574
|
+
comments: {
|
|
575
|
+
type: "comment";
|
|
576
|
+
schema: "customSchema";
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
## Mixed data (dynamic type)
|
|
582
|
+
|
|
583
|
+
### Serialize
|
|
584
|
+
|
|
585
|
+
If your data contains one or multiple objects of different types, it's possible to define a configuration object instead of the type-string as the first argument of `serialize` and `serializeAsync` with these options:
|
|
586
|
+
|
|
587
|
+
* **type** (required): A _string_ for the path to the key to use to determine type or a _function_ deriving a type-string from each data-item.
|
|
588
|
+
* **jsonapiObject** (optional): Enable/Disable [JSON API Object](http://jsonapi.org/format/#document-jsonapi-object). Default = true.
|
|
589
|
+
* **topLevelMeta** (optional): Describes the top-level meta. It can be:
|
|
590
|
+
* An _object_ (values can be string or function).
|
|
591
|
+
* A _function_ with one argument `function(extraData) { ... }` or with two arguments `function(data, extraData) { ... }`
|
|
592
|
+
* **topLevelLinks** (optional): Describes the top-level links. It can be:
|
|
593
|
+
* An _object_ (values can be string or function).
|
|
594
|
+
* A _function_ with one argument `function(extraData) { ... }` or with two arguments `function(data, extraData) { ... }`
|
|
595
|
+
|
|
596
|
+
Example :
|
|
597
|
+
|
|
598
|
+
```javascript
|
|
599
|
+
const typeConfig = {
|
|
600
|
+
// Same as type: 'type'
|
|
601
|
+
type: data => data.type // Can be very complex to determine different types of items.
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
Serializer.serializeAsync(typeConfig, data, { count: 2 }).then(result => {
|
|
605
|
+
// ...
|
|
606
|
+
});
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
### Deserialize
|
|
610
|
+
|
|
611
|
+
If your data contains one or multiple objects of different types, it's possible to define a configuration object instead of the type-string as the first argument of `deserialize` with these options:
|
|
612
|
+
|
|
613
|
+
* **type** (required): A _string_ for the path to the key to use to determine type or a _function_ deriving a type-string from each data-item.
|
|
614
|
+
|
|
615
|
+
Example :
|
|
616
|
+
|
|
617
|
+
```javascript
|
|
618
|
+
const typeConfig = {
|
|
619
|
+
// Same as type: 'type'
|
|
620
|
+
type: data => data.type // Can be very complex to determine different types of items.
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
const deserialized = Serializer.deserializeAsync(typeConfig, data).then(result => {
|
|
624
|
+
// ...
|
|
625
|
+
});
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
## Custom serialization and deserialization
|
|
629
|
+
|
|
630
|
+
If your data requires some specific transformations, those can be applied using `beforeSerialize` and `afterDeserialize`
|
|
631
|
+
|
|
632
|
+
Example for composite primary keys:
|
|
633
|
+
|
|
634
|
+
```javascript
|
|
635
|
+
Serializer.register('translation', {
|
|
636
|
+
beforeSerialize: (data) => {
|
|
637
|
+
// Exclude pk1 and pk2 from data
|
|
638
|
+
const { pk1, pk2, ...attributes } = data;
|
|
639
|
+
|
|
640
|
+
// Compute external id
|
|
641
|
+
const id = `${pk1}-${pk2}`;
|
|
642
|
+
|
|
643
|
+
// Return data with id
|
|
644
|
+
return {
|
|
645
|
+
...attributes,
|
|
646
|
+
id
|
|
647
|
+
};
|
|
648
|
+
},
|
|
649
|
+
afterDeserialize: (data) => {
|
|
650
|
+
// Exclude id from data
|
|
651
|
+
const { id, ...attributes } = data;
|
|
652
|
+
|
|
653
|
+
// Recover PKs
|
|
654
|
+
const [pk1, pk2] = id.split('-');
|
|
655
|
+
|
|
656
|
+
// Return data with PKs
|
|
657
|
+
return {
|
|
658
|
+
...attributes,
|
|
659
|
+
pk1,
|
|
660
|
+
pk2,
|
|
661
|
+
};
|
|
662
|
+
},
|
|
663
|
+
});
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
## Benchmark
|
|
667
|
+
|
|
668
|
+
```bash
|
|
669
|
+
Platform info:
|
|
670
|
+
==============
|
|
671
|
+
Darwin 18.7.0 x64
|
|
672
|
+
Node.JS: 10.16.3
|
|
673
|
+
V8: 6.8.275.32-node.54
|
|
674
|
+
Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz × 8
|
|
675
|
+
|
|
676
|
+
Suite:
|
|
677
|
+
==============
|
|
678
|
+
serializeAsync x 80,043 ops/sec ±0.74% (78 runs sampled)
|
|
679
|
+
serialize x 135,669 ops/sec ±1.12% (88 runs sampled)
|
|
680
|
+
serializeConvertCase x 98,785 ops/sec ±2.34% (88 runs sampled)
|
|
681
|
+
deserializeAsync x 172,832 ops/sec ±0.41% (82 runs sampled)
|
|
682
|
+
deserialize x 393,979 ops/sec ±0.32% (91 runs sampled)
|
|
683
|
+
deserializeConvertCase x 119,021 ops/sec ±1.76% (95 runs sampled)
|
|
684
|
+
serializeError x 276,346 ops/sec ±1.07% (86 runs sampled)
|
|
685
|
+
serializeError with a JSON API error object x 15,783,113 ops/sec ±1.74% (88 runs sampled)
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
## License
|
|
689
|
+
|
|
690
|
+
[MIT](https://github.com/danivek/json-api-serializer/blob/master/LICENSE)
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# JSON:API Serde - Server
|
|
2
|
+
|
|
3
|
+
[](https://github.com/DASPRiD/jsonapi-serde-js/actions/workflows/test.yml)
|
|
4
|
+
[](https://codecov.io/gh/DASPRiD/jsonapi-serde-js)
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
JSON:API Serde is a framework-agnostic [JSON:API](https://jsonapi.org) serialization and deserialization library.
|
|
9
|
+
|
|
10
|
+
## Documentation
|
|
11
|
+
|
|
12
|
+
To check out docs, visit [jsonapi-serde.js.org](https://jsonapi-serde.js.org).
|
|
13
|
+
|
|
14
|
+
## Changelog
|
|
15
|
+
|
|
16
|
+
Detailed changes for each release are documented in the [CHANGELOG](https://github.com/dasprid/jsonapi-serde-js/blob/main/packages/server/CHANGELOG.md)
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
[BSD-3-Clause](https://github.com/dasprid/jsonapi-serde-js/blob/main/LICENSE)
|
|
21
|
+
|
|
22
|
+
Copyright (c) 2025-present, Ben Scholzen 'DASPRiD'
|