fortunejs / fortune-json-api

JSON API serializer for Fortune.
MIT License
63 stars 28 forks source link

Can I use `InflectType: false` for a single type? #57

Closed rhettl closed 5 years ago

rhettl commented 5 years ago

Hello,

This is in reference to fortunejs/fortune#311 I can see in the readme and in #12 that I could turn off all type inflection by using something like this

const store = fortune({
  faculty: {
    projects: Array(String),
    supportGiven: [ Array('support'), 'faculty' ],
    initialCredit: Number,
  },
  support: {
    faculty: [ 'faculty', 'supportGiven' ],
    notes: String,
    quarter: String,
    created: Date
  },
  user: { /* ... */ }
}, {
  adapter: adapter, // mongo adapter
  hooks: { /* ... */ }, 
  serializers: [{
        type: require('fortune-json-api'),
        options: {
            inflectType: false
        }
    }],
});

It is possible to turn off inflectType for only for only faculty. My actual system error is from a POST /api/support:

Fri, 01 Feb 2019 18:22:44 GMT finalhandler default 409
Fri, 01 Feb 2019 18:22:44 GMT finalhandler cannot 409 after headers sent
ConflictError: Data object field "type" is invalid, it must be "faculties", not "faculty".
gr0uch commented 5 years ago

Not currently though I would welcome a PR.

rhettl commented 5 years ago

I will read into the code and see what I can do 👍