mirror of
https://github.com/typicode/json-server.git
synced 2025-07-30 13:42:11 +08:00
Add --read-only option
This commit is contained in:
@ -47,5 +47,16 @@ module.exports = function (opts) {
|
||||
next()
|
||||
})
|
||||
|
||||
// Read-only
|
||||
if (opts.readOnly) {
|
||||
arr.push(function (req, res, next) {
|
||||
if (req.method === 'GET') {
|
||||
next() // Continue
|
||||
} else {
|
||||
res.sendStatus(403) // Forbidden
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return arr
|
||||
}
|
||||
|
Reference in New Issue
Block a user