restify-mock
A mock server for Restful API powered by restify (add OPTIONS method to all routes automatically to support Cross-origin resource sharing)
Get start
cd /path/to/projectnpm init -ynpm i restify-mock
Usage
- serve
const MockServer = ;// or verbose mode, pass true to the first argumentconst server = ; // #loadAndServe(), load a json fileserver;// or #serve(), load from js objectserver;
- config
const MockServer LoggingLevel = ;// not change #loggingLevel or #bodyFormatter after invoking the constructorconst server = LoggingLevelHEADERS { if statusCode >= 200 && statusCode < 300 return success: true message: message data: data ; else return success: false message: message ; }; serverbaseUrl = '/api/v1';// just a example, use addHttpBasicInterceptor(username, password) instead ofserver;
routes.json