-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpatchUpdate.js
More file actions
26 lines (24 loc) · 969 Bytes
/
patchUpdate.js
File metadata and controls
26 lines (24 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env node
import express from 'express'
const router = express.Router()
//This controller will handle all MongoDB interactions.
import controller from '../db-controller.js'
import rest from '../rest.js'
import auth from '../auth/index.js'
router.route('/')
.patch(auth.checkJwt, rest.verifyJsonContentType, controller.patchUpdate)
.post(auth.checkJwt, rest.verifyJsonContentType, (req, res, next) => {
if (!rest.checkPatchOverrideSupport(req, res)) {
res.statusMessage = 'Improper request method for updating, please use PATCH to alter the existing keys this object.'
res.status(405)
next(res)
return
}
controller.patchUpdate(req, res, next)
})
.all((req, res, next) => {
res.statusMessage = 'Improper request method for updating, please use PATCH to alter existing keys on this object.'
res.status(405)
next(res)
})
export default router