fakie
MOCK API MADE EASY Simple server or fetch mock up API powered by faker.js and express.
npm i -S fakie
- Need a mock API with random content? templates
- Wanna use it as a standalone server? FakieServer
- Wanna use it as a router in express? createRouter
- Wanna use it as a fetch mock up directly in the client? FakieClient
Templates
const fakie = ;const getAllUsers =;const getUser =;
FakieServer
const FakieServer = ;const server =// locale: localizes some of the values e.g. the nameslocale: 'de'// seed: number other than 0 - enforces to receive always the same results !!! doesn't work with dates !!!seed: 11092323routes:methods: 'GET'path: '/users'// handler: template object or functionhandler: getAllUsersmethods: 'GET'path: '/user/:username'// handler: template object or functionhandler: getUser;server;
as router
const FakieServer FakieClient = ;// via createRouterconst routerA = FakieServer;// via FakieServer instanceconst routerB = /*config*/router;
FakieClient
const FakieClient = ;const client =host: 'http://localhost'routes:path: '/users'handler: getAllUsers;client;