A simple full-stack note-taking application built with Node.js, Express, MongoDB, and a vanilla HTML/CSS/JS frontend. Includes JWT authentication so multiple users can register, log in, and manage their own notes securely.
- User registration & authentication (JWT-based)
- Create, read, update, and delete personal notes
- Validation & error handling on server-side
- Clean, minimal front-end interface with HTML, CSS, and JS
- RESTful API endpoints for integration or external use
git clone https://github.com/your-username/note-taking-app.git
cd note-taking-appnpm installCreate a .env file in the root with the following variables:
PORT=3000
MONGO_URI=mongodb://localhost:27017/notetakingapp
JWT_SECRET=your_jwt_secret_herenpm startServer will run on http://localhost:3000.
Visit http://localhost:3000 to:
- Register/Login as a user
- Add, edit, and delete notes
- View your personal note collection
All protected routes require an Authorization header:
Authorization: Bearer <your_token>Register a new user.
// Request
{
"email": "user@example.com",
"password": "securepassword"
}
// Response
{
"token": "<jwt_token>",
"user": {
"id": "1234567890",
"email": "user@example.com"
}
}Log in an existing user.
// Request
{
"email": "user@example.com",
"password": "securepassword"
}
// Response
{
"token": "<jwt_token>",
"user": {
"id": "1234567890",
"email": "user@example.com"
}
}Fetch all notes for the logged-in user.
// Response
{
"success": true,
"count": 2,
"data": [
{
"_id": "note123",
"title": "Shopping List",
"content": "Milk, Bread, Eggs",
"user": "1234567890"
},
{
"_id": "note456",
"title": "Todo",
"content": "Finish project",
"user": "1234567890"
}
]
}Create a new note.
// Request
{
"title": "New Note",
"content": "This is a test note."
}
// Response
{
"success": true,
"data": {
"_id": "note789",
"title": "New Note",
"content": "This is a test note.",
"user": "1234567890"
}
}Update an existing note.
// Request
{
"title": "Updated Title",
"content": "Updated content."
}
// Response
{
"success": true,
"data": {
"_id": "note789",
"title": "Updated Title",
"content": "Updated content.",
"user": "1234567890"
}
}Delete a note.
// Response
{
"success": true,
"data": {}
}The API returns structured error responses:
{
"success": false,
"error": "Validation error: Title is required"
}Common error cases:
- Missing fields (e.g., no
titleorpassword) - Invalid credentials on login
- Unauthorized access to another user’s note
- Fork the repository
- Create a new branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m 'Add my feature') - Push to your branch (
git push origin feature/my-feature) - Open a Pull Request
This project is licensed under the MIT License.