A RESTful backend server for a note-taking application, built with Node.js, Express, and MongoDB. This backend allows for user authentication, note creation, and retrieval with JWT-based authorization.
- Features
- Getting Started
- Environment Variables
- Installation
- Running the Server
- API Endpoints
- Dependencies
- User authentication (registration and login) using JWT
- Secure password hashing with bcrypt
- CRUD operations for user notes
- Middleware-based request validation and authorization
- Configurable CORS settings
Ensure you have the following prerequisites:
- Node.js: >=14.0.0
- MongoDB: Local instance or MongoDB Atlas for cloud hosting
Create a .env file in the root directory with the following:
PORT=3400
MONGODB_URL= Your MongoDB URL
Clone the repository: git clone https://github.com/04amanrajj/note-app-backend.git cd note-app-backend
npm install
To start the server, run: npm run server
The server will start on the specified port (default: 3400).
POST /user/register: Register a new userPOST /user/login: Log in an existing user and receive a JWT token
GET /note: Retrieve all notes (Requires authentication)POST /note: Create a new note (Requires authentication)PUT /note/<id>: Update a note by ID (Requires authentication)DELETE /note/<id>: Delete a note by ID (Requires authentication)
- express: Web framework for Node.js
- mongoose: MongoDB object modeling
- jsonwebtoken: JWT implementation for secure authentication
- bcrypt: Password hashing for security
- dotenv: Manage environment variables
- cors: Enable Cross-Origin Resource Sharing