@feizheng/json-server-multiple
v1.0.1
Published
Multiple apis support for json server.
Downloads
2
Readme
json-server-multiple
Multiple apis support for json server.
installation
npm i -S @feizheng/json-server-multiple
usage
// config.js
import path from 'path';
export const MOUNT_POINT = '/api/v1/';
export const DB_JSON = path.join(__dirname, './database/db.json');
export const STRINGIFY_INDENT = 2;
export const APIS = path.join(__dirname, './apis');
// app.js
import JsonServer from 'json-server';
import JsonServerMultiple from 'json-server-multiple';
import {
MOUNT_POINT,
DB_JSON,
APIS
} from './config';
// create multiple apis
JsonServerMultiple.create(DB_JSON, APIS);
const server = JsonServer.create();
const router = JsonServer.router(DB_JSON);
const middlewares = JsonServer.defaults();
server.use(middlewares);
server.use(router);
server.use(MOUNT_POINT, router);
server.listen(3001, () => {
console.log('JSON Server is running')
});
resouces
+ https://github.com/Marak/faker.js
license
Code released under the MIT license.