This is a RESTful API for managing bookmarks built with NestJS. The API allows users to create, retrieve, update, and delete bookmarks. It also provides user management features such as user registration and authentication using JSON Web Tokens (JWT). The API utilizes Prisma as the ORM and PostgreSQL as the database. Docker is used for easy setup and management of the database.
Make sure you have the following installed:
- Node.js
- Yarn package manager
- Docker
-
Clone the repository:
$ git clone <repository-url> $ cd bookmark-api
-
Install dependencies:
$ yarn install
-
Start the PostgreSQL database using Docker:
$ yarn db:dev:up
-
Run database migrations:
$ yarn prisma:dev:deploy
-
Start the API in development mode:
$ yarn start:dev
The API is now running and accessible at http://localhost:3333
.
-
GET /users/me
Retrieves the currently authenticated user.
-
PATCH /users
Updates the profile information of the authenticated user.
-
GET /bookmarks
Retrieves all bookmarks belonging to the authenticated user.
-
GET /bookmarks/:id
Retrieves a specific bookmark by its ID.
-
POST /bookmarks
Creates a new bookmark for the authenticated user.
-
PATCH /bookmarks/:id
Updates a specific bookmark by its ID.
-
DELETE /bookmarks/:id
Deletes a specific bookmark by its ID.
The API uses JSON Web Tokens (JWT) for authentication. To authenticate and access protected endpoints, include the JWT token in the Authorization
header as follows:
Authorization: Bearer <JWT_TOKEN>
Replace <JWT_TOKEN>
with the actual JWT token obtained during the authentication process.
To run the API tests, use the following command:
$ yarn test:e2e
The API uses PostgreSQL as the database. Docker is used for easy database setup and management. The database configuration can be found in the .env
file.
To start the development database:
$ yarn db:dev:up
To start the test database:
$ yarn db:test:up