Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JSON Server to deploy data

License

NotificationsYou must be signed in to change notification settings

ikramdeveloper/json-server-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instructions how to deploy the full fake REST APIjson-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 greenUse this template-button in the right corner ofthis repo
  2. Give your new repo a name and press the greenCreate repository from template-button
  3. Clone your newly created repository to your computer

4 . Change the contents ofdb.json toyour own content according to thejson-server example and thencommit your changes to git locally.

this example will create/posts route , each resource will haveid,title andcontent.id will auto increment!

{"posts": [    {"id":0,"title":"First post!","content":"My first content!"    }  ]}

Deploy to Glitch

Not tested 100%. Same as with Heroku, will sleep after a while.

  1. Register forGlitch or go toGlitch/edit
  2. ClickNew Project
  3. ClickImport from GitHub
  4. Pastehttps://github.com/ikramdeveloper/json-server-deploy into the URL-input and click OK.
  5. Wait for it to setup
  6. PressShare-button to get your URL to live site. It should be something for example like:https://seemly-truthful-scribe.glitch.me/. And your DB will be athttps://seemly-truthful-scribe.glitch.me/posts

Deploy toHeroku

Heroku

Heroku is a free hosting service for hosting small projects. Easy setup and deploy from the command line viagit.

Pros
  • Easy setup
Cons
  • Premium
  • App has to sleep a couple of hours every day.
  • "Powers down" after 30 mins of inactivity. Starts back up when you visit the site but it takes a few extra seconds. Can maybe be solved withKaffeine

Install Heroku

1 .Create your database

2 . Create an account on
https://heroku.com

3 . Install the Heroku CLI on your computer:
https://devcenter.heroku.com/articles/heroku-cli

4 . Connect the Heroku CLI to your account by writing the following command in your terminal and follow the instructions on the command line:

heroku login

5 . Then create a remote heroku project, kinda like creating a git repository on GitHub. This will create a project on Heroku with a random name. If you want to name your app you have to supply your own name likeheroku create project-name:

heroku create my-cool-project

6 . Push your app toHeroku (you will see a wall of code)

git push heroku master

7 . Visit your newly create app by opening it via heroku:

heroku open

8 . For debugging if something went wrong:

heroku logs --tail

How it works

Heroku will look for a startup-script, this is by defaultnpm start so make sure you have that in yourpackage.json (assuming your script is calledserver.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 herokus port. So the code will have the following:

constport=process.env.PORT||4000;

Author Links

👋 Hello, I'm Ikram Ul Haq - Web Developer & Programmer

Buy Me A Coffee

🚀 Follow Me:

About

JSON Server to deploy data

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp