This repository contains code for the back end of the notes web app. It is a RESTful server built using Node.js runtime and Express framework, and can perform all the CRUD operations and other database queries on the MongoDB database. I've used MongoDB Atlas as a database and have defined the routes, models using Mongoose.
These instructions will help you to set up the server on your local machine for development.
- Node.js - a JavaScript runtime
- Git - for cloning and version control
- Nodemon - to automatically restart server when file changes in the directory are detected.
- Follow these instructions to get started with MongoDB Atlas
- Click on the COLLECTIONS button of your cluster and create two databases inside it :
- notes_app
- test
- Inside each database, create two collections named :
- notes
- users
- The final structure of your cluster should look something like this :
Cluster0 // Your main cluster |_ notes_app // Database #1 - Main Database | |_ notes // (Collection) - All the user notes are saved here | |_ users // (Collection) - User information is saved here |_ test // Database #2 - For testing |_ notes // (Collection) - Test notes |_ users // (Collection) - Test users
- Finally, click on the CONNECT button of your cluster -> Select Connect your application and note the uri.
NOTE : Replace <password> with the password for your username. Replace <dbname> with the name of the database, i.e. notes_app for ATLAS_URI and test for ATLAS_TEST_URI.
- Follow these instructions to generate the CLIENT_ID and CLIENT_SECRET
- While generating OAuth Client ID :
- Add following URIs to Authorized JavaScript origins :
- http://localhost:3000
- http://localhost:5000
- Add following URI to Authorized redirect URIs section :
- http://localhost:5000/auth/google/callback
- Add following URIs to Authorized JavaScript origins :
Clone this repository using the following command inside the terminal/cmd
git clone https://github.com/siddheshkothadi/notes-backend
cd notes-backend
-
Paste the previously generated ATLAS_URI (by replacing <dbname> with notes_app), ATLAS_TEST_URI (by replacing <dbname> with test), CLIENT_ID and CLIENT_SECRET inside .env file. You can set any value for COOKIE_KEY.
Run the folowing command to install the dependencies
npm install
OR
yarn
Finally, run the server
npm run dev
Hurray! Your server should be running on PORT 5000
- You've setup the server. Now, you can start the front end for notes web app or you can test GET, POST, PUT, DELETE requests using Postman.
This project is licensed under the MIT License - see the LICENSE.md file for details