mirror of
https://github.com/typicode/json-server.git
synced 2025-07-31 14:12:38 +08:00
eslint --fix
This commit is contained in:
@ -53,30 +53,28 @@ module.exports = (source, opts = { foreignKeySuffix: 'Id' }) => {
|
||||
router.use(nested(opts))
|
||||
|
||||
// Create routes
|
||||
db
|
||||
.forEach((value, key) => {
|
||||
if (_.isPlainObject(value)) {
|
||||
router.use(`/${key}`, singular(db, key))
|
||||
return
|
||||
}
|
||||
db.forEach((value, key) => {
|
||||
if (_.isPlainObject(value)) {
|
||||
router.use(`/${key}`, singular(db, key))
|
||||
return
|
||||
}
|
||||
|
||||
if (_.isArray(value)) {
|
||||
router.use(`/${key}`, plural(db, key, opts))
|
||||
return
|
||||
}
|
||||
if (_.isArray(value)) {
|
||||
router.use(`/${key}`, plural(db, key, opts))
|
||||
return
|
||||
}
|
||||
|
||||
var sourceMessage = ''
|
||||
if (!_.isObject(source)) {
|
||||
sourceMessage = `in ${source}`
|
||||
}
|
||||
var sourceMessage = ''
|
||||
if (!_.isObject(source)) {
|
||||
sourceMessage = `in ${source}`
|
||||
}
|
||||
|
||||
const msg =
|
||||
`Type of "${key}" (${typeof value}) ${sourceMessage} is not supported. ` +
|
||||
`Use objects or arrays of objects.`
|
||||
const msg =
|
||||
`Type of "${key}" (${typeof value}) ${sourceMessage} is not supported. ` +
|
||||
`Use objects or arrays of objects.`
|
||||
|
||||
throw new Error(msg)
|
||||
})
|
||||
.value()
|
||||
throw new Error(msg)
|
||||
}).value()
|
||||
|
||||
router.use((req, res) => {
|
||||
if (!res.locals.data) {
|
||||
|
@ -299,8 +299,7 @@ module.exports = (db, name, opts) => {
|
||||
// Remove dependents documents
|
||||
const removable = db._.getRemovable(db.getState(), opts)
|
||||
removable.forEach(item => {
|
||||
db
|
||||
.get(item.name)
|
||||
db.get(item.name)
|
||||
.removeById(item.id)
|
||||
.value()
|
||||
})
|
||||
|
@ -27,8 +27,7 @@ module.exports = (db, name) => {
|
||||
if (req.method === 'PUT') {
|
||||
db.set(name, req.body).value()
|
||||
} else {
|
||||
db
|
||||
.get(name)
|
||||
db.get(name)
|
||||
.assign(req.body)
|
||||
.value()
|
||||
}
|
||||
|
Reference in New Issue
Block a user