{"id":20054769,"url":"https://github.com/abhi5658/rest-api-node-express-mongodb","last_synced_at":"2026-04-12T13:47:04.395Z","repository":{"id":88356571,"uuid":"241099963","full_name":"abhi5658/rest-api-node-express-mongodb","owner":"abhi5658","description":null,"archived":false,"fork":false,"pushed_at":"2020-04-06T07:53:48.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-12T21:32:12.383Z","etag":null,"topics":["body-parser","express","heroku","heroku-app","heroku-cli","heroku-deployment","heroku-master","mongo","mongodb","mongoose","node","nodemon","now","now-sh","package-json","rest","rest-api","secret"],"latest_commit_sha":null,"homepage":"https://rest-api-node-abhi.herokuapp.com/","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/abhi5658.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-17T12:16:54.000Z","updated_at":"2020-04-06T07:53:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"fa46a9ac-ba26-4908-8f16-712a3c6ba918","html_url":"https://github.com/abhi5658/rest-api-node-express-mongodb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhi5658%2Frest-api-node-express-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhi5658%2Frest-api-node-express-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhi5658%2Frest-api-node-express-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhi5658%2Frest-api-node-express-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhi5658","download_url":"https://codeload.github.com/abhi5658/rest-api-node-express-mongodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241483379,"owners_count":19970074,"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","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":["body-parser","express","heroku","heroku-app","heroku-cli","heroku-deployment","heroku-master","mongo","mongodb","mongoose","node","nodemon","now","now-sh","package-json","rest","rest-api","secret"],"created_at":"2024-11-13T12:43:12.993Z","updated_at":"2026-04-12T13:46:59.348Z","avatar_url":"https://github.com/abhi5658.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rest-api-node-express-mongodb\n\n## Contents of [process.md](process.md) below:\n\n### Steps:\n- create project folder\n- `npm init -y`\n- create index.js; add dummy code\n- `node src/index.js`\n- add \"start\": \"node src/index.js\" in scripts in package.json\n- `npm start` OR `npm run start`\n- `npm install express`\n- use express, listen : check\n- create route : check\n- install nodemon : `npm i nodemon -D`\n    - -D to install(download) and run nodemon only during development\n- add \"start-watch\": \"nodemon src/index.js\" in scripts in package.json\n- new command to start server with nodemon : `npm run start-watch`\n- install mongoose : `npm i mongoose`\n- install body parser: `npm i body-parser`\n- install now.sh CLI globally(system wide) : `npm i now -g` [not using now.sh as it works good for serverless function]\n- process.env.PORT added \u0026 addd PORT number in start in package.json\n\n### Setting up mongodb\n- Sign up on mongodb.com\n- New project auto-created on new cluster creation\n- Create a new Cluster\n- Select provider [preferably aws]\n- Select nearest region [Mumbai (ap-south-1)]\n- Enter cluster name\n- Create Cluster\n- Create user in Database Access tab\n- Add IP address in Network Access tab [whitelist for all if needed]\n- After cluster build success click connect\n- Get connection string\n- Edit user and password in connection string\n\n### Setting up Heroku app against node project\n- create heroku account\n- install heroku CLI\n- goto local project git directory\n- login into heroku cli : `heroku login`\n- enter credentials -\u003e login success\n- try running project locally as heroku project: `heroku local web`\n- heroku starts server on port 5000! the code has been designed to accept port from external environment\n- create heroku project: `heroku create` : this creates a git project assosiated to heroku\n- push commited project to heroku master branch : `git push heroku master` : makes the project live at returned url\n- created **secret** branch based on master: `git checkout -b secret master`\n- staging credential file back to secret branch : `git update-index --no-skip-worktree src/models/db_credential.js`\n- commit changes in secret branch\n- push secret branch to heroku master to have correct credentials to mongodb : `git push heroku secret:master` : db works correctly\n    - Changing app name and url at heroku: https://devcenter.heroku.com/articles/renaming-apps#updating-git-remotes\n    - Goto project directory with heroku logged in\n    - rename command syntax:`heroku apps:rename newname --app oldname` : `heroku apps:rename rest-api-node-abhi --app polar-ravine-43913`\n    - Update git remotes : \n        - 1st command : `git remote rm heroku`\n        - 2nd command : `heroku git:remote -a newname`\n\n### package.json versioning\n- example -\u003e \"express\": \"^4.17.1\"\n- Given a version number MAJOR.MINOR.PATCH, increment the MAJOR version when you make incompatible API changes, MINOR version when you add functionality in a backwards-compatible manner, and PATCH version when you make backwards-compatible bug fixes.\n- npm uses the tilde (~) and caret (^) to designate which patch and minor versions to use respectively.\n- So if you see ~1.0.2 it means to install version 1.0.2 or the latest patch version such as 1.0.4.\n- If you see ^1.0.2 it means to install version 1.0.2 or the latest minor or patch version such as 1.1.0.\n- Patch releases: 1.0 or 1.0.x or ~1.0.4\n- Minor releases: 1 or 1.x or ^1.0.4\n- Major releases: * or x\n\n### Older way of creating routes\n- [http module for Node.js server](https://blog.risingstack.com/your-first-node-js-http-server/#thehttpmoduleforyournodejsserver)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhi5658%2Frest-api-node-express-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhi5658%2Frest-api-node-express-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhi5658%2Frest-api-node-express-mongodb/lists"}