Skip to content

Instantly share code, notes, and snippets.

@TracyNgot
Created November 22, 2018 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TracyNgot/4221c49d4560c02d34ea4c7cb6424a61 to your computer and use it in GitHub Desktop.
Save TracyNgot/4221c49d4560c02d34ea4c7cb6424a61 to your computer and use it in GitHub Desktop.
Mock Server With ExpressJS, Typescript and JSON
interface Mock {
pathname: string;
method: string;
status: number;
responseBody: JSON;
}
class MockRoutes {
mockRoutes: Mock[] = [];
constructor() {
this.initMockRoutes();
}
private initMockRoutes() {
this.mockRoutes.push({
pathname: '/your-path',
method: 'GET',
status: 200,
responseBody: require('../mocks/response.json')
});
}
}
export default new MockRoutes().mockRoutes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment