A node.js server for notes app.
The server runs in node.js using Express to setup a server to listen to requests to API endpoints and /resetpassword
route.
- Sets up middleware for Rate Limiting, Passport (used for authentication), Body Parser (used for JSON).
- Connects to the MongoDB using Mongoose for CRUD operations.
- Express server to serve API endpoints &
/resetpassword
webpage
This repo contains the following:
/sync
: Realtime synching of notes to the Database, called every 5 seconds from notes-clent app./sendall
: Send All notes to the client, called every 5 seconds from the notes-client app./new
: Create a new note in the DB./delete
: Delete the selected note from the DB./logout
: Log out the current authenticated user.
The below endpoints are moved to the repo notes-server-lambda as I've split it into AWS Lambda function!
/login
: For login of users./register
: To register new users./forgotpassword
: To send a reset mail to the registered email address of the user./resetpassword
: To handle reset password functionality.
Note: API endpoints '/sync', /sendall
, /new
, /delete
and /logout
need to be authenticated by Passport.js to work. The client needs to send the JSON webtoken through the Authorization header. Please see the notes-client for how the API calls are made.
The /resetpassword
POST Request is handled by sending the /resetpassword/index.html
webpage back to the user, where they can enter relevant details to reset the password.
A mail is triggered to the user with the nodemailer package, you will need to setup your existing email Id for this. Or you can create a new one. You have to create a 'app password' (Gmail/Yahoo/etc.. each have their own way of generating app passwords, please consult the relevant documentation as per your requirements) and use it to send mails!
This project has a code coverage of 100% with functional as well as unit tests written with care.
Have fun with the code!