Instructions how to deploy the full fake REST API json-server to various free hosting sites. Should only be used in development purpose but can act as a simpler database for smaller applications.
- Press the green
Use this template
-button in the right corner - Give your new repo a name and press the green
Create repository from template
-button - Clone your newly created repository to your computer
4 . Change the contents of db.json
to your own content according to the json-server example
and then commit
your changes to git locally.
this example will create /posts
route , each resource will have id
, title
and content
. id
will auto increment!
{
"posts": [
{
"id": 0,
"title": "First post!",
"content": "My first content!"
}
]
}
The Render Public API is a REST API that lets you manage all of your Render services and resources through simple HTTP requests. With this API, you can have all the power of the Render dashboard through your own scripts, allowing you to integrate seamlessly with Render through your own scripts. git.
- Easy setup
- Free
1 . Create an account on
https://render.com
2 . New > Web Service
3 . Used https://github.com/pratikderepatil/json-server repo.
4 . Added a Build Command of npm install
5 . Added a Start Command of npm start
The deploy was successful.
Render will look for a startup-script, this is by default npm start
so make sure you have that in your package.json
(assuming your script is called server.js
):
"scripts": {
"start" : "node server.js"
}
You also have to make changes to the port, you can't hardcode a dev-port. But you can reference render port. So the code will have the following:
const port = process.env.PORT || 3000;