Json server powered by express.js that works on AWS Lambda
This project provides a json mock server which can be deployed on AWS Labda leveraging serverless-http
core functionalities.
There is no installation so to say, you just have to clone this repo and you are good to go.
git clone https://github.com/ItsBhatt/json-server.git
json-server
takes advantage of serverless-http
package which acts as a wrapper and exported as a handler supported by AWS Lambda. It can be deployed on serverless functions as well as on normal servers.
- helpers -> Parsing the req + generating response
- db.json -> Mock data which will be used for response generation
- index.js -> Root File
- routes.js -> express server routes
After clonning the repo you can simply add you mock json data inside db.json
on the root directory.
It can be deployed on any platform(server/serverless) and it works seamlessly.
Asuming you have already created api and lambda function
Step 1 - Just create a .zip of all files including node_modules.
Step 2 - Open your labda function and upload the .zip file.
Step 3 - Add a environment variable ENVIRONMENT=production
.
Step 4 - Deploy the function 🎊 .
You can simply deploy this as an express app on any server.