This is an API for notes. It allows you to create, read, update, delete, share and search for notes.
- Express.js for server side API framework
- Mongoose MongoDB ORM
- JWT for authentication
- Swagger for API documentation
- express-rate-limit for API rate limiting
- bcrypt for password hashing
/README.mdpackage.json(contains project dependencies)/tests(test files for API endpoints)/models(mongoose schemas for notes)/controllers(business logic for the API)/routes(API routes definition)/middlewares(middlewares for API routes)/config(configuration files)
Copy .env.example to .env and fill in the required values
cp .env.example .env
When running locally .env file be used by docker-compose.dev.yml file to fee env vars to containers
There are two options to setup the API locally:
- Deploy Everything with Docker (Simplest way to get it running)
- Setup the API with DB on your host machine directly
docker-compose -f docker-compose.dev.yml up --build -dto start the API server and mongodbThis will start API server with container name
notes_api_devand mongodb container with namenotes_api_mongodb_dev- To connect with MongoDB in host machine with. for example mongodb compass use URI as
mongodb://<DB_USER>:<DB_PASSWORD>@127.0.0.1:27019/UserNotes - For running tests use
docker exec -it notes_api_dev npm run dev-test dev-testwill generate test coverage reports in./coveragein html format- Hot reloading is enabled in
docker-compose.dev.yml
-
Prepare a MongoDB database at
mongodb://127.0.0.1:27017/UserNotes. Instructions for setting up MongoDB can be found here -
Run
npm installto install dependencies -
Run
npm run devto start the API server -
Test the API with
npm run dev-test
-
After server is running, go to
http://localhost:<5000 | PORT given in .env>and test the API -
To test the API with Swagger UI, go to
http://localhost:<5000 | PORT given in .env>/api-docs/index.html -
To check test coverage open
<directory_path_to_repo_root>/notes_api/coverage/index.html. For coverage files to be generated you first need to run thes test withnpm test