This is a REST API for managing notes. It uses Express.js for the server and MongoDB for the database.
- Create, read, update, and delete notes.
- API routes are under
/api/v1
. - Data is stored in MongoDB.
-
Install dependencies:
npm install
-
Set up environment variables: Copy
.env.example
file in the root directory and paste it with a new name.env
and configure its values with yours:API_ROUTE_PREFIX='/api/v1' DATABASE_CONNECTION_STRING='mongodb://localhost:27017'
-
Start the server:
npm start
For development with auto-reloading:
npm run dev
The server will run on port 3000 by default.
-
Get all notes
GET /api/v1/notes
- Returns a list of all notes.
-
Get a note by ID
GET /api/v1/notes/:id
- Returns a note by its ID.
-
Create a note
POST /api/v1/notes
- Body:
{ "title": "string", "text": "string" }
- Creates a new note.
-
Update a note
PATCH /api/v1/notes/:id
- Body:
{ "title": "string", "text": "string" }
- Updates an existing note by its ID.
-
Delete a note
DELETE /api/v1/notes/:id
- Deletes a note by its ID.
400 Bad Request
: For invalid data or errors with the request.404 Not Found
: When a note is not found.500 Internal Server Error
: For server or database issues.
-
Dependencies:
body-parser
: Parses request bodies.express
: Server framework.mongoose
: MongoDB object modeling.
-
DevDependencies:
dotenv
: Loads environment variables.nodemon
: Auto-reloads server during development.
- Repository: GitHub Repo
- Issues: Issue Tracker
- Homepage: Project Homepage