This is a toy project for a headless CMS built with NestJS and MongoDB, enabling users to create, delete, and partially manage their posts, establish relationships between them, and engage in discussions through comments.
To get started with this project, you can choose to either run the project natively on your machine, or with Docker.
To run the project natively, you will need to have Node.js v22.9.0 or higher and npm v10.8.3 or higher installed on your machine.
npm install
to install the necessary dependencies.npm start
to start the server.To run the project with Docker, you will need to have Docker installed on your machine.
# The MongoDB connection string for the BlogPost database
MONGODB_URI="mongodb://mongodb/test"
# The port on which the Blog CMS API will run
PORT="3000"
# The seed string to be used for the JwtStrategy
JWT_SECRET="42"
docker compose build
to build the containers.docker compose up
to start the containers.http://localhost:3000/
.Once the server is running, you can use the following endpoints to manage your blog posts:
GET /api/v1/posts
: Returns a list of all posts.POST /api/v1/posts
: Creates a new post.GET /api/v1/posts?page&limit
: Get Posts with pagination based on created date.GET /api/v1/posts?slug=:slug
: Returns a specific post by slug.GET /api/v1/posts/:id
: Returns a specific post by post ID.DELETE /api/v1/posts/:id
: Deletes a post by post ID.GET /api/v1/posts/:id/relations
: Returns relationship posts by post IDPOST /api/v1/posts/relation/?sourcePostId&relationPostId
: Sets a relationship between two posts.GET /heath
: Returns useful system information, such as server uptime and memory usage. This endpoint can be used to monitor the health of the application.Note: The current pagination implementation is based on the page
and limit
query parameters and orders the results based on created date in ascending order.
Here are some potential improvements that could be made to this project:
Here are the tasks that have already been completed in this project:
Contributions to this project are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request.
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.