Skip to content

About Get a full fake REST API with zero coding in less than 30 seconds (seriously)

Notifications You must be signed in to change notification settings

pratikderepatil/json-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploy json-server to {{ free hosting site }}

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.

Create your database

  1. Press the green Use this template-button in the right corner
  2. Give your new repo a name and press the green Create repository from template-button
  3. 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!"
		}
	]
}

Deploy to Render

Render

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.

Pros
  • Easy setup
  • Free

Deployment

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.

How it works

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;

About

About Get a full fake REST API with zero coding in less than 30 seconds (seriously)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published