This is a simple API that allows you to make CRUD operations on a database. It was made using Nest.js, Prisma ORM, Passport.js (JWT) and PostgreSQL.
Consists of 4 main modules:
- Auth: Handles the authentication and authorization of the users using Passport.js and JWT.
- Users: Handles the CRUD operations of the users.
- Posts: Handles the CRUD operations of the posts.
- Comments: Handles the CRUD operations of the comments.
With the following routes:
- Auth:
/api/v1/users
POST /sign_up
POST /sign_in
- Users:
/api/v1/users
(protected)GET /
GET /me
Get the current user infoPATCH /
Update the current user infoPATCH /change_password
Change the current user passwordPATCH /change_role
Change the current user role (admin only)DELETE /
Delete the current user account
- Posts:
/api/v1/posts
(protected)GET /
All PUBLISHED postsGET /:id
Get a PUBLISHED postPOST /
PATCH /:id
DELETE /:id
- Comments:
/api/v1/comments
(protected)GET /:postId
Get all comments of a postPOST /:postId
Create a comment on a postPATCH /:id
Update a commentDELETE /:id
Delete a comment
With 2 types of E2E tests:
- Using Cucumber.js (Gherkin), SuperTest and Chai
- Using Jest and Pactum
$ npm install
# start the development database (docker)
$ docker-compose up -d dev-db
# migrate the database and seed it with data
$ npm run prisma:dev:deploy
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
With Cucumber.js (Gherkin), SuperTest and Chai
$ npm run test:e2e:cucumber
With Jest and Pactum
$ npm run test:e2e:pactum