Created
November 22, 2018 21:03
-
-
Save TracyNgot/4221c49d4560c02d34ea4c7cb6424a61 to your computer and use it in GitHub Desktop.
Mock Server With ExpressJS, Typescript and JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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