├── .gitignore ├── README.md ├── db.json ├── index.js ├── package-lock.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # render-json-server 2 | 3 | ## Watch This Video 4 | [![Click to watch the video](http://img.youtube.com/vi/wN0n2gj0z9o/0.jpg)](http://www.youtube.com/watch?v=wN0n2gj0z9o) 5 | 6 | 7 | Hello everyone in this video you will learn to deploy your db.json file on **render.com** step by step. 8 | 9 | **Step 1** - Create git repository 10 | 11 | **Step 2** - Clone it on your device 12 | 13 | **Step 3** - Add package.json by using this command `npm init -y` 14 | 15 | **Step 4** - Install some dependency by using this command `npm i json-server cors json-serve` and add ` "start": "node index.js" ` in script 16 | 17 | **Step 6** - Create index.js file copy the code from my GitHub repository 18 | 19 | ```javaScript 20 | const jsonServer = require("json-server"); // importing json-server library 21 | const server = jsonServer.create(); 22 | const router = jsonServer.router("db.json"); 23 | const middlewares = jsonServer.defaults(); 24 | const port = process.env.PORT || 8080; // chose port from here like 8080, 3001 25 | 26 | server.use(middlewares); 27 | server.use(router); 28 | 29 | server.listen(port); 30 | 31 | ``` 32 | 33 | **Step 7** - Add db.json and add .gitignore file 34 | 35 | 36 | After all this steps are completed use this command to push the code in your Github account. 37 | 38 | `git add .` 39 | 40 | `git commit -m "Your message"` 41 | 42 | `git push origin main` 43 | 44 | 45 | If you find this video helpful please subscribe to my channel and share this with your friends. If you have any queries ask in the comment section below I will be happy to answer you all. 46 | -------------------------------------------------------------------------------- /db.json: -------------------------------------------------------------------------------- 1 | { 2 | "sunglasses" : [ 3 | { 4 | "id": 81, 5 | "title": "Round Silver Frame Sun Glasses", 6 | "description": "A pair of sunglasses can protect your eyes from being hurt. For car driving, vacation travel, outdoor activities, social gatherings,", 7 | "price": 19, 8 | "discountPercentage": 10.1, 9 | "rating": 4.94, 10 | "stock": 78, 11 | "brand": "Designer Sun Glasses", 12 | "category": "sunglasses", 13 | "thumbnail": "https://i.ebayimg.com/thumbs/images/g/M44AAOSwthxjVGaT/s-l300.webp", 14 | "images": [ 15 | "https://i.dummyjson.com/data/products/81/1.jpg", 16 | "https://i.dummyjson.com/data/products/81/2.jpg", 17 | "https://i.dummyjson.com/data/products/81/3.jpg", 18 | "https://i.dummyjson.com/data/products/81/4.webp", 19 | "https://i.dummyjson.com/data/products/81/thumbnail.jpg" 20 | ] 21 | }, 22 | { 23 | "id": 82, 24 | "title": "Kabir Singh Square Sunglass", 25 | "description": "Orignal Metal Kabir Singh design 2020 Sunglasses Men Brand Designer Sun Glasses Kabir Singh Square Sunglass", 26 | "price": 50, 27 | "discountPercentage": 15.6, 28 | "rating": 4.62, 29 | "stock": 78, 30 | "brand": "Designer Sun Glasses", 31 | "category": "sunglasses", 32 | "thumbnail": "https://i.ebayimg.com/thumbs/images/g/OAQAAOSwNihj0PSm/s-l300.webp", 33 | "images": [ 34 | "https://i.dummyjson.com/data/products/82/1.jpg", 35 | "https://i.dummyjson.com/data/products/82/2.webp", 36 | "https://i.dummyjson.com/data/products/82/3.jpg", 37 | "https://i.dummyjson.com/data/products/82/4.jpg", 38 | "https://i.dummyjson.com/data/products/82/thumbnail.jpg" 39 | ] 40 | }, 41 | { 42 | "id": 83, 43 | "title": "Wiley X Night Vision Yellow Glasses", 44 | "description": "Wiley X Night Vision Yellow Glasses for Riders - Night Vision Anti Fog Driving Glasses - Free Night Glass Cover - Shield Eyes From Dust and Virus- For Night Sport Matches", 45 | "price": 30, 46 | "discountPercentage": 6.33, 47 | "rating": 4.97, 48 | "stock": 115, 49 | "brand": "mastar watch", 50 | "category": "sunglasses", 51 | "thumbnail": "https://i.ebayimg.com/thumbs/images/g/cLsAAOSwV1JjZbJ4/s-l300.webp", 52 | "images": [ 53 | "https://i.dummyjson.com/data/products/83/1.jpg", 54 | "https://i.dummyjson.com/data/products/83/2.jpg", 55 | "https://i.dummyjson.com/data/products/83/3.jpg", 56 | "https://i.dummyjson.com/data/products/83/4.jpg", 57 | "https://i.dummyjson.com/data/products/83/thumbnail.jpg" 58 | ] 59 | }, 60 | { 61 | "id": 84, 62 | "title": "Square Sunglasses", 63 | "description": "Fashion Oversized Square Sunglasses Retro Gradient Big Frame Sunglasses For Women One Piece Gafas Shade Mirror Clear Lens 17059", 64 | "price": 28, 65 | "discountPercentage": 13.89, 66 | "rating": 4.64, 67 | "stock": 64, 68 | "brand": "mastar watch", 69 | "category": "sunglasses", 70 | "thumbnail": "https://i.ebayimg.com/thumbs/images/g/x4UAAOSwcjhgg84n/s-l300.webp", 71 | "images": [ 72 | "https://i.dummyjson.com/data/products/84/1.jpg", 73 | "https://i.dummyjson.com/data/products/84/2.jpg", 74 | "https://i.dummyjson.com/data/products/84/thumbnail.jpg" 75 | ] 76 | }, 77 | { 78 | "id": 85, 79 | "title": "LouisWill Men Sunglasses", 80 | "description": "LouisWill Men Sunglasses Polarized Sunglasses UV400 Sunglasses Day Night Dual Use Safety Driving Night Vision Eyewear AL-MG Frame Sun Glasses with Free Box for Drivers", 81 | "price": 50, 82 | "discountPercentage": 11.27, 83 | "rating": 4.98, 84 | "stock": 92, 85 | "brand": "LouisWill", 86 | "category": "sunglasses", 87 | "thumbnail": "https://i.dummyjson.com/data/products/85/thumbnail.jpg", 88 | "images": [ 89 | "https://i.dummyjson.com/data/products/85/1.jpg", 90 | "https://i.dummyjson.com/data/products/85/2.jpg", 91 | "https://i.dummyjson.com/data/products/85/thumbnail.jpg" 92 | ] 93 | } 94 | ] 95 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const jsonServer = require("json-server"); // importing json-server library 2 | const server = jsonServer.create(); 3 | const router = jsonServer.router("db.json"); 4 | const middlewares = jsonServer.defaults(); 5 | const port = process.env.PORT || 8080; // chose port from here like 8080, 3001 6 | 7 | server.use(middlewares); 8 | server.use(router); 9 | 10 | server.listen(port); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "render-json-server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/UmaSahni/render-json-server.git" 13 | }, 14 | "keywords": [], 15 | "author": "", 16 | "license": "ISC", 17 | "bugs": { 18 | "url": "https://github.com/UmaSahni/render-json-server/issues" 19 | }, 20 | "homepage": "https://github.com/UmaSahni/render-json-server#readme", 21 | "dependencies": { 22 | "cors": "^2.8.5", 23 | "json-serve": "^0.1.0", 24 | "json-server": "^0.17.1" 25 | } 26 | } 27 | --------------------------------------------------------------------------------