stub-api-server
v0.6.12
Published
Stub REST api with fake JSON
Downloads
19
Readme
stub-api-server
This lib allows you to configure an HTTP server responding dynamic fake JSON.
The common usecase is stubbing a REST API for Integration Tests.
Introduction
stub-api-server allow you to define an endpoint based on a simple object
// routes/route.ts
import { RouteConfig } from 'stub-api-server';
const route: RouteConfig = {
method: 'GET',
path: '/hello',
template: { message: 'Hello World' },
};
export default route;
// index.ts
import path from 'path';
import { StubApiServer } from 'stub-api-server';
const server = new StubApiServer();
server.useRoutesFromDir(path.resolve('./routes'));
server.start();
➜ ts-node index.ts
Starting server on http://localhost:8000