- To build a secure and scalable RESTful API that allows users to create, read, update, and delete notes.
- The application should also allow users to share their notes with other users and search for notes based on keywords.
- Implement a RESTful API using a framework of your choice (e.g. Express, DRF, Spring).
- Use a database of your choice to store the data (preferably MongoDB or PostgreSQL).
- Use any authentication protocol and implement a simple rate limiting and request throttling to handle high traffic.
- Implement search functionality to enable users to search for notes based on keywords. ( preferably text indexing for high performance )
- Write unit tests and integration tests your API endpoints using a testing framework of your choice.
# I've used bun as a package manager
## Setup
bun install
bun db:generate # generate prisma schema
bun db:push # pushsearch
ing the schema and creating a sqlite db
## Starting the Dev Env
bun dev # Start the server
bun db:studio # prisma studio
Your API should implement the following endpoints:
- POST /api/auth/sign-up: create a new user account.
{
"username": "imskanand",
"email": "[email protected]",
"password": "123"
}
- POST /api/auth/sign-in: log in to an existing user account and receive an access token.
NOTE Put the token you get from the sign-in/sign-up in these routes because these routes are authorized only
- GET /api/notes: get a list of all notes for the authenticated user.
- GET /api/notes/:id: get a note by ID for the authenticated user.
- POST /api/notes: create a new note for the authenticated user.
{
"noteContent": "You are the champion!"
}
- PUT /api/notes/:id: update an existing note by ID for the authenticated user.
{
"noteContent": "Hello Bro!!"
}
- DELETE /api/notes/:id: delete a note by ID for the authenticated user.
- GET /api/search?q=:query: search for notes based on keywords for the authenticated user.