-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
29 lines (25 loc) · 1.04 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// server.js
'use strict'
const jsonServer = require('json-server');
const _jsonExtender = require('json-server-extension');
//options:
//fullPath:fullpath for the combined object
//generatedPath:the path where the generated files will be found
//staticPath:the path where the static files will be found
const jsonExtender = new _jsonExtender({filePath:'./db_extends.json',
generatedPath:'./generated',
staticPath:'./static'})
//register accacpt array of generators or path to the generator scripts
//const funcs = Object.keys(generators).map(key => generators[key])
jsonExtender.register('../../../generators');
jsonExtender.generate().then((data)=>{
console.log(`wow ${data}`);
var server = jsonServer.create()
var router = jsonServer.router('./db_extends.json')
var middlewares = jsonServer.defaults()
server.use(middlewares)
server.use(router)
server.listen(4000, function () {
console.log('JSON Server is running')
})
}).catch((e) => {console.log(e)});