Simple API for building cool blogs
Crafted using Nest.js
+ MongoDB
This API provides the ability to create simple blogs with markdown markup based on an already created system of posts and comments. For convenient blogging, there is an administrator authorization service with a set of secure routes. The comments service does not require registration, but all comments can be verified by administrators.
- Clone this repository
- Create
.env
file with connection URI and JWT secret key
DATABASE_URI=mongodb://mongodb0.example.com:27017
JWT_SECRET=PasteYourJwtSecret
- Install all packages
npm install
- Run server for development/production
npm run start:dev
npm run start
- Build docker image
docker build . -t blog-api
- Launch containter
docker run -p 3000:3000 --env-file .env --name server blog-api
You can use a specially prepared collection of endpoints for Insomnia client. For this just import ./blog-api.insomnia.json
file.
Method | URI | Body (JSON) | Action |
---|---|---|---|
POST |
/api/auth/register | { โ "email": "example@mail.com", โ "password": "example" } |
Registration for admins |
POST |
/api/auth/login | { โ "email": "example@mail.com", โ "password": "example" } |
Login for admins |
Method | URI | Body (JSON) | Action |
---|---|---|---|
POST |
/api/post | { โ "category": "category", โ "title": "title", โ "image": "test.png", โ "tags": ["one", "two"], โ "content": "Hello World!" } |
Create post (For admins) |
GET |
/api/post/id |
none |
Find post by id |
GET |
/api/post/withComments/id |
none |
Find post by id with comments |
POST |
/api/post/find/id |
{ โ "category": "category", โ "limit": 100 } |
Find posts by category |
PATCH |
/api/post/id |
{ โ "category": "category", โ "title": "title", โ "image": "test.png", โ "tags": ["one", "two"], โ "content": "Hello World!" } |
Update post by id (For admins) |
DELETE |
/api/post/id |
none |
Delete post by id (For admins) |
Method | URI | Body (JSON) | Action |
---|---|---|---|
POST |
/api/comment | { โ "author": "Author", โ "email": "test@mail.com", โ "content": "Hello World!", โ "postId": id } |
Create comment for post |
GET |
/api/comment/id |
none |
Find comment by id |
GET |
/api/comment/byPost/id |
none |
Find comment by post id |
GET |
/api/comment/verified/id |
none |
Verified comment by id (For admins) |
DELETE |
/api/comment/id |
none |
Delete comment by id (For admins) |