Backend API for personal notes CRUD with user ownership using JWT and HttpOnly cookies.
- Register user
- Login user
- Logout user
- Create note
- Get all notes (user-specific)
- Get single note (user-specific)
- Update note (user-specific)
- Delete note (user-specific)
- Protected routes
- JWT authentication
- HttpOnly cookie based auth
- MongoDB with Mongoose
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT
- bcryptjs
- cookie-parser
Create a .env file:
PORT=1202
MONGO_URI=mongodb://127.0.0.1:27017/backend_notes_api
JWT_SECRET=your_secret_key
NODE_ENV=developmentnpm installnpm run dev- POST /api/auth/register
- POST /api/auth/login
- POST /api/auth/logout
- POST /api/notes
- GET /api/notes
- GET /api/notes/:id
- PUT /api/notes/:id
- DELETE /api/notes/:id
- Each note belongs to a specific user
- Users can only access their own notes
- Authentication via HttpOnly cookies
- Use withCredentials: true in frontend
- GitHub: https://github.com/a2rp
- Portfolio: https://www.ashishranjan.net
- LinkedIn: https://www.linkedin.com/in/aashishranjan
- Facebook: https://www.facebook.com/theash.ashish/
- YouTube: https://www.youtube.com/@ashishranjan-ashz