⚠️ Nodejs 8 is no longer supported by Firebase. To use Node 11 you have to add payment method. The concept described here should apply to Node 11 as well, minor modification may be required.
A simple mock API server using Express.js that is hosted on Firebase.
You have full control of what API to define and what data to respond with with minimal coding.
See medium article https://link.medium.com/OAjz9kkV0U on how to setup firebase project and setup mock server.
The APIs are defined via Express.js framework and served though Firebase cloud functions. All the defined API can be found at 👉 functions/index.js 👈 and pre-loaded mock responses example can be found at mock-responses
- References: https://expressjs.com/en/guide/routing.html
https://mock-apis-server.firebaseapp.com/say/hello
https://mock-apis-server.firebaseapp.com/say/hello?name=Ryan
https://mock-apis-server.firebaseapp.com/users/myid
Success
curl -X POST \
https://mock-apis-server.firebaseapp.com/register \
-H 'Content-Type: application/json' \
-d '{"userId": "myusername", "email":"my@email.com", "name": "New User"}'
Fail
curl -X POST \
https://mock-apis-server.firebaseapp.com/register \
-H 'Content-Type: application/json' \
-d '{"userId": "taken", "email":"existing@email.com", "name": "Existing User"}'
NOTE: You will have to use terminal to execute these curl commands.
https://mock-apis-server.firebaseapp.com/photos
https://mock-apis-server.firebaseapp.com/photos/29647
Using firebase console you can easily update the database values to reflect new values in realtime without needing to touch JSON source files.