mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 20:52:08 +08:00
Use lodash-id
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
"express": "^4.9.5",
|
"express": "^4.9.5",
|
||||||
"json-parse-helpfulerror": "^1.0.3",
|
"json-parse-helpfulerror": "^1.0.3",
|
||||||
"lodash": "^4.11.2",
|
"lodash": "^4.11.2",
|
||||||
|
"lodash-id": "^0.13.0",
|
||||||
"lowdb": "^0.15.0",
|
"lowdb": "^0.15.0",
|
||||||
"method-override": "^2.1.2",
|
"method-override": "^2.1.2",
|
||||||
"morgan": "^1.3.1",
|
"morgan": "^1.3.1",
|
||||||
@ -25,7 +26,6 @@
|
|||||||
"request": "^2.72.0",
|
"request": "^2.72.0",
|
||||||
"server-destroy": "^1.0.1",
|
"server-destroy": "^1.0.1",
|
||||||
"shortid": "^2.2.6",
|
"shortid": "^2.2.6",
|
||||||
"underscore-db": "^0.12.2",
|
|
||||||
"update-notifier": "^1.0.2",
|
"update-notifier": "^1.0.2",
|
||||||
"yargs": "^6.0.0"
|
"yargs": "^6.0.0"
|
||||||
},
|
},
|
||||||
|
@ -34,7 +34,7 @@ function getRemovable (db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return incremented id or uuid
|
// Return incremented id or uuid
|
||||||
// Used to override underscore-db's createId with utils.createId
|
// Used to override lodash-id's createId with utils.createId
|
||||||
function createId (coll) {
|
function createId (coll) {
|
||||||
const _ = this
|
const _ = this
|
||||||
const idProperty = _.__id()
|
const idProperty = _.__id()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const express = require('express')
|
const express = require('express')
|
||||||
const methodOverride = require('method-override')
|
const methodOverride = require('method-override')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const _db = require('underscore-db')
|
const lodashId = require('lodash-id')
|
||||||
const low = require('lowdb')
|
const low = require('lowdb')
|
||||||
const fileAsync = require('lowdb/lib/storages/file-async')
|
const fileAsync = require('lowdb/lib/storages/file-async')
|
||||||
const bodyParser = require('../body-parser')
|
const bodyParser = require('../body-parser')
|
||||||
@ -30,8 +30,8 @@ module.exports = (source) => {
|
|||||||
|
|
||||||
validateData(db.getState())
|
validateData(db.getState())
|
||||||
|
|
||||||
// Add underscore-db methods to db
|
// Add lodash-id methods to db
|
||||||
db._.mixin(_db)
|
db._.mixin(lodashId)
|
||||||
|
|
||||||
// Add specific mixins
|
// Add specific mixins
|
||||||
db._.mixin(mixins)
|
db._.mixin(mixins)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const _db = require('underscore-db')
|
const lodashId = require('lodash-id')
|
||||||
const mixins = require('../../src/server/mixins')
|
const mixins = require('../../src/server/mixins')
|
||||||
|
|
||||||
describe('mixins', () => {
|
describe('mixins', () => {
|
||||||
let db
|
let db
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
_.mixin(_db)
|
_.mixin(lodashId)
|
||||||
_.mixin(mixins)
|
_.mixin(mixins)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user