mirror of
https://github.com/typicode/json-server.git
synced 2025-07-30 13:42:11 +08:00
Error message for incorrect export type from db js file
This commit is contained in:
@ -16,7 +16,13 @@ module.exports = function (source, cb) {
|
||||
|
||||
var filename = path.resolve(source)
|
||||
delete require.cache[filename]
|
||||
data = require(filename)()
|
||||
var dataFn = require(filename)
|
||||
|
||||
if (typeof dataFn !== 'function') {
|
||||
throw new Error('The database is a JavaScript file but the export is not a function.')
|
||||
}
|
||||
|
||||
data = dataFn()
|
||||
cb(null, data)
|
||||
|
||||
} else if (is.JSON(source)) {
|
||||
|
Reference in New Issue
Block a user