Skip to content

Commit

Permalink
eslint --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed May 30, 2018
1 parent 4a8d8c8 commit 50baa9e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
46 changes: 22 additions & 24 deletions src/server/router/index.js
Expand Up @@ -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
}

if (_.isArray(value)) {
router.use(`/${key}`, plural(db, key, opts))
return
}

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.`

throw new Error(msg)
})
.value()
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
}

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.`

throw new Error(msg)
}).value()

router.use((req, res) => {
if (!res.locals.data) {
Expand Down
3 changes: 1 addition & 2 deletions src/server/router/plural.js
Expand Up @@ -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()
})
Expand Down
3 changes: 1 addition & 2 deletions src/server/router/singular.js
Expand Up @@ -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()
}
Expand Down

0 comments on commit 50baa9e

Please sign in to comment.