This project provides a multi-level comment system API designed to handle nested comments with features such as creating posts, adding comments with nested replies, and pagination. The system is built with Node.js, Express, and PostgreSQL, and it is Dockerized for easy deployment.
- API s
- Running Locally
- Run Tests
- Postman Collection Json
- License
- Endpoint:
POST http://localhost:4001/api/auth/register
- Request Body:
{ "username": "string", "password": "string" }
- Endpoint:
POST https://localhost:4001/api/auth/login
- Request Body:
{ "username": "string", "password": "string" }
The following APIs require an authorization token. You can obtain the JWT token from the login response.
- Endpoint:
POST https://localhost:4001/api/posts/create-post
- Request Headers:
-
Authorization: Bearer <token>
- Request Body:
{ "content": "new post", "userId": 2 }
- Endpoint:
POST http://localhost:4001/api/posts/3/comments
- Request Headers:
-
Authorization: Bearer <token>
- Request Body:
{ "text": "nice", "postId": 3 }
- Endpoint:
POST http://localhost:4001/api/posts/3/comments/4/reply
- Request Headers:
-
Authorization: Bearer <token>
- Request Body:
{ "postId": 3, "commentId": 4, "text": "second reply" }
- Request Headers:
-
Authorization: Bearer <token>
- Endpoint:
http://localhost:4001/api/posts/3/comments?sortBy=repliesCount&sortOrder=desc
- Request Headers:
-
Authorization: Bearer <token>
- Endpoint:
http://localhost:4001/api/posts/3/comments/4/expand?page=1&pageSize=10
- Clone Repository: Begin by cloning the repository to your local machine.
- Add ENV : Add env files in the root as well as prisma folder. You can find sample in
sample.env.function
andsample.env
, which indicate where they are required. - Install Dependancies: Execute the following commands in your terminal:
npm i
- Start Application: Execute the following commands in your terminal:
npm run start
- Execute the following commands in your terminal:
npm run test
For detailed API documentation and to test the endpoints, you can use the provided Postman collection. The postman-collection.json
file is located in the root directory of this repository.
This collection includes pre-configured requests for all available API endpoints, making it easier to explore and test the API directly in Postman.
This project is licensed under the MIT License.