Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC6902 enabled #323

Closed
wants to merge 3 commits into from
Closed

RFC6902 enabled #323

wants to merge 3 commits into from

Conversation

fairsayan
Copy link

I implemented RFC6902 as suggested in the #224 issue.
Some caveats:

  1. mongoose-json-patch must be pluged by the user in schema definition. I tried to plug it addressing model.schema inside express-restify-mongoose module without success.
  2. The structure of this module is a chain of middlewares and it was too hard for me to distinguish the behavior between PATCH with application/json and the one with application/json-patch+json. So in my implementation PATCH with application/json doesn't use findOneAndUpdate even if the correspondent option is true because I needed to run the filterAndFindById instead.
  3. To use this implementation bodyParser.json has to accept application/json-patch+json content type as well so in the application must be declared something like:
    router.use (bodyParser.json({strict:false, type: (req) => {
    var ct = req.headers['content-type'];
    return (ct === 'application/json-patch+json') || (ct === 'application/json');
    }}));

    otherwise req.body will be empty and won't be applied any patch.

@Zertz
Copy link
Collaborator

Zertz commented Jan 14, 2017

What happens if the user doesn't have mongoose-json-patch installed?

@fairsayan
Copy link
Author

@Zertz a big crash

@fairsayan fairsayan closed this Feb 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants