File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const JSONAPISerializer = require ( 'jsonapi-serializer' ) . Serializer ;
3+
4+ function jsonapify ( data , model , selfUrl ) {
5+ return new JSONAPISerializer ( model . name , data , {
6+ topLevelLinks : {
7+ self : selfUrl
8+ } ,
9+ attributes : Object . keys ( model . attributes ) . filter ( function ( attribute ) {
10+ return ! model . attributes [ attribute ] . primaryKey ;
11+ } )
12+ } ) ;
13+ }
14+
15+ module . exports = function ( options = { } ) { // eslint-disable-line no-unused-vars
16+ return function ( hook ) {
17+ hook . result = jsonapify ( hook . result . data , hook . service . Model , hook . path ) ;
18+ return Promise . resolve ( hook ) ;
19+ } ;
20+ } ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " feathers-hooks-jsonapify" ,
3+ "version" : " 0.0.0" ,
4+ "description" : " Feathers hook for outputting data in a JSON-API-compliant way. Edit" ,
5+ "main" : " index.js" ,
6+ "repository" : {
7+ "type" : " git" ,
8+ "url" : " git+https://github.com/joelalejandro/feathers-hooks-jsonapify.git"
9+ },
10+ "keywords" : [
11+ " feathers" ,
12+ " hook" ,
13+ " json-api"
14+ ],
15+ "author" : " Joel A. Villarreal Bertoldi <joel.a.villarreal@gmail.com>" ,
16+ "license" : " MIT" ,
17+ "bugs" : {
18+ "url" : " https://github.com/joelalejandro/feathers-hooks-jsonapify/issues"
19+ },
20+ "homepage" : " https://github.com/joelalejandro/feathers-hooks-jsonapify#readme" ,
21+ "dependencies" : {
22+ "jsonapi-serializer" : " ^3.5.2"
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments