{"id":18781965,"url":"https://github.com/akshay-singh-rajput/deploy-your-json-server","last_synced_at":"2025-07-22T06:04:24.676Z","repository":{"id":59459849,"uuid":"497763667","full_name":"Akshay-Singh-Rajput/Deploy-Your-Json-Server","owner":"Akshay-Singh-Rajput","description":"Here you can learn how to deploy you mock-server(db.json) file to heroku.","archived":false,"fork":false,"pushed_at":"2022-05-31T03:29:00.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T12:31:32.103Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Akshay-Singh-Rajput.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-30T02:30:34.000Z","updated_at":"2022-05-30T02:36:27.000Z","dependencies_parsed_at":"2022-09-16T19:51:57.348Z","dependency_job_id":null,"html_url":"https://github.com/Akshay-Singh-Rajput/Deploy-Your-Json-Server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Akshay-Singh-Rajput/Deploy-Your-Json-Server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akshay-Singh-Rajput%2FDeploy-Your-Json-Server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akshay-Singh-Rajput%2FDeploy-Your-Json-Server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akshay-Singh-Rajput%2FDeploy-Your-Json-Server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akshay-Singh-Rajput%2FDeploy-Your-Json-Server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Akshay-Singh-Rajput","download_url":"https://codeload.github.com/Akshay-Singh-Rajput/Deploy-Your-Json-Server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akshay-Singh-Rajput%2FDeploy-Your-Json-Server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266437369,"owners_count":23928235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T20:34:25.560Z","updated_at":"2025-07-22T06:04:24.649Z","avatar_url":"https://github.com/Akshay-Singh-Rajput.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deploy-Your-Json-Server to Heroku or any free hosting sites\nHere you can see how to deploy you mock-server(db.json) file to heroku.\n\n### You can clone this repo and change your db.json data with your data and start deploying or\n\n## Create Your Own Fake Server.\n\n1. Create a folder and name it any name or fake_server.\n2. Create a file and make the entry point server.js\n3. Open the folder in editor and open terminal and let's Start\n4. ```npm init``` \n5. ```npm i json-server```\n6. Add a ```start``` script in ```package.json```\n7. Your ```package.json``` should look like this or you can paste this code in your ```package.json```\n```json\n{\n  \"name\": \"fake-server\",\n  \"version\": \"1.0.0\",\n  \"description\": \"fake server with fake database\",\n  \"main\": \"server.js\",\n  \"scripts\": { // \u003c=== \n    \"start\": \"node server.js\" // \u003c===\n  },\n  \"author\": \"Akshay Kumar\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"json-server\": \"^0.16.3\" \n  }\n}\n```\n8. create ```.gitignore``` file and add ```node_modules``` ```.gitignore```\n9. Open ```server.js``` file and paste the following code\n```js\nconst jsonServer = require('json-server');\nconst server = jsonServer.create();\nconst router = jsonServer.router('db.json'); // file name of your database\nconst middlewares = jsonServer.defaults();\nconst port = process.env.PORT || 4000; // You can change the port\n\nserver.use(middlewares);\nserver.use(router);\n\nserver.listen(port);\n```\n10. Create ***db.json*** file\nFill in any data you like, or use [Mockaroo](https://www.mockaroo.com/?target=_blank) which is a great and easy way to generate dummy data.\n```json\n{\n  \"users\": [\n    {\n      \"id\": 1,\n      \"first_name\": \"Justina\",\n      \"last_name\": \"Ginglell\",\n      \"email\": \"jginglell0@networkadvertising.org\",\n      \"gender\": \"Female\"\n    },\n    {\n      \"id\": 2,\n      \"first_name\": \"Marion\",\n      \"last_name\": \"Jenman\",\n      \"email\": \"mjenman1@surveymonkey.com\",\n      \"gender\": \"Male\"\n    },\n    {\n      \"id\": 3,\n      \"first_name\": \"Alfy\",\n      \"last_name\": \"Begin\",\n      \"email\": \"abegin2@list-manage.com\",\n      \"gender\": \"Female\"\n    },\n    {\n      \"id\": 4,\n      \"first_name\": \"Karney\",\n      \"last_name\": \"Zanussii\",\n      \"email\": \"kzanussii3@hao123.com\",\n      \"gender\": \"Male\"\n    },\n    {\n      \"id\": 5,\n      \"first_name\": \"Reid\",\n      \"last_name\": \"Schapero\",\n      \"email\": \"rschapero4@timesonline.co.uk\",\n      \"gender\": \"Male\"\n    },\n    {\n      \"id\": 6,\n      \"first_name\": \"Dorine\",\n      \"last_name\": \"Braybrookes\",\n      \"email\": \"dbraybrookes5@gov.uk\",\n      \"gender\": \"Female\"\n    },\n    {\n      \"id\": 7,\n      \"first_name\": \"Sarena\",\n      \"last_name\": \"Frape\",\n      \"email\": \"sfrape6@alexa.com\",\n      \"gender\": \"Female\"\n    },\n    {\n      \"id\": 8,\n      \"first_name\": \"Malva\",\n      \"last_name\": \"Pierse\",\n      \"email\": \"mpierse7@usda.gov\",\n      \"gender\": \"Female\"\n    },\n    {\n      \"id\": 9,\n      \"first_name\": \"Rania\",\n      \"last_name\": \"Dablin\",\n      \"email\": \"rdablin8@state.gov\",\n      \"gender\": \"Female\"\n    },\n    {\n      \"id\": 10,\n      \"first_name\": \"Ingrim\",\n      \"last_name\": \"Offen\",\n      \"email\": \"ioffen9@slideshare.net\",\n      \"gender\": \"Male\"\n    }\n  ]\n}\n```\n\n## Deploy to **Heroku**\n\n\u003cimg align=\"right\" width=\"100px\" height=\"auto\" src=\"https://cdn.worldvectorlogo.com/logos/heroku.svg\" alt=\"Heroku\"\u003e\n\nHeroku is a free hosting service for hosting small projects. Easy setup and deploy from the command line via _git_.\n\n###### Pros\n\n* Easy setup\n* Free\n\n###### Cons\n\n* App has to sleep a couple of hours every day.\n* \"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 with [**Kaffeine**](http://kaffeine.herokuapp.com/)\n\n---\n\n### Install Heroku\n\n1 . [Create your database](#create-your-database)\n\n2 . Create an account on \u003cbr/\u003e[https://heroku.com](https://heroku.com)\n\n3 . Install the Heroku CLI on your computer: \u003cbr/\u003e[https://devcenter.heroku.com/articles/heroku-cli](https://devcenter.heroku.com/articles/heroku-cli)\n\n4 . Connect the Heroku CLI to your account by writing the following command in your terminal and follow the instructions on the command line:\n```bash\nheroku login\n```\n\n5 . 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 like `heroku create project-name`:\n```bash\nheroku create my-cool-project\n```\n\n6 . Push your app to __Heroku__ (you will see a wall of code)\n```bash\ngit push heroku master\n```\n\n7 . Visit your newly create app by opening it via heroku:\n```bash\nheroku open\n```\n\n8 . For debugging if something went wrong:\n```bash\nheroku logs --tail\n```\n\n---\n\n#### How it works\n\nHeroku 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`):\n```json\n \"scripts\": {\n    \"start\" : \"node server.js\"\n }\n```\n\nYou 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:\n```js\nconst port = process.env.PORT || 4000;\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakshay-singh-rajput%2Fdeploy-your-json-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakshay-singh-rajput%2Fdeploy-your-json-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakshay-singh-rajput%2Fdeploy-your-json-server/lists"}