A simple CRUD API for note making using MongoDB and Express.
- Install dependencies:
npm install
-
Make sure MongoDB is running locally or update the connection string in
index.jsto your MongoDB URI. -
Start the server:
npm start
The server will run on port 3000 by default.
-
POST /notes- Create a new note.
Request body example:{ "title": "Sample Note", "content": "This is a sample note." } -
GET /notes- Get all notes. -
GET /notes/:id- Get a note by ID. -
PUT /notes/:id- Update a note by ID.
Request body can include fields to update, e.g. title or content. -
DELETE /notes/:id- Delete a note by ID.
- The API uses MongoDB with Mongoose ODM.
- The note schema includes
title(required),content, andcreatedAtfields.