Skip to content

Example demonstrating the use of express to quickly create a mock API

License

Notifications You must be signed in to change notification settings

hiebj/express-mock-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-mock-api

Example demonstrating the use of express to quickly create a mock API.

This technique serves as a valuable means to populate views with test data even if a live API for said data is not readily available. The resulting endpoints.js and mock JSON data files can be used as a reference when coordinating contract specification with the developers of the production API.

This is a simplified, code-over-configuration approach comparable to using api-mock with APIBlueprint, but which allows you to use your own development server and does not require you to learn a complicated API descriptor syntax.

This technique can be combined with express-http-proxy to conditionally proxy API calls to a remote service for live testing instead of local mocking.

Run the example

npm install  
npm start [port = 8080]

Use curl, Postman or a similar tool to make a request that has a response mapped in mock-api/endpoints.js.

About

Example demonstrating the use of express to quickly create a mock API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published