Updated mock-api to serve with a little delay. Also added possibility to change the delay
This commit is contained in:
@@ -1,9 +1,24 @@
|
||||
import commandLineArgs from 'command-line-args';
|
||||
import pause from 'connect-pause';
|
||||
import jsonServer from 'json-server';
|
||||
|
||||
const optionDefinitions = [
|
||||
{
|
||||
name: 'delay',
|
||||
description: 'Add a delay in ms to the server. Defaults to 200.',
|
||||
alias: 'd',
|
||||
type: Number,
|
||||
defaultValue: 200,
|
||||
},
|
||||
];
|
||||
|
||||
const options = commandLineArgs(optionDefinitions);
|
||||
|
||||
const server = jsonServer.create();
|
||||
const router = jsonServer.router('api.json');
|
||||
const middlewares = jsonServer.defaults();
|
||||
|
||||
server.use(pause(options.delay));
|
||||
server.use(middlewares);
|
||||
|
||||
server.use(
|
||||
|
||||
Reference in New Issue
Block a user