* This was made as a submission for an interview assignment, so marking this as an archived repo!
This is the implementation for how I think the backend of a blogging platform like Medium would function.
Note There is a warning when starting the server which looks like
Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
According to a MongoDB Employee, this is a warning that will be fixed in the next release and is safe to ignore.
These endpoints don't require authentication
- Register user :
POST /user/register
- Login user :
POST /user/login
- Get user details :
GET /user/:id
- Get all blogs :
GET /blog
- Get a specific blog :
GET /blog/:id
- Search blogs using tags:
GET /blog/search
Closed endpoints require a valid Token to be included in the header of the request. A Token can be acquired from the Login (check above).
The token should be passed as the value of the header called Authorization
.
- Follow user :
POST /user/follow
- Unfollow user :
POST /user/unfollow
- Delete user :
DELETE /user
- Post blog :
POST /blog
- Delete blog :
DELETE /blog
- Clap on blog :
POST /blog/clap
- Comment on blog :
POST /blog/comment
- Delete Comment from blog :
DELETE /blog/comment
These are the features that I have not implemented due to time contraints but could be done in the same way as the others
- Updating blogs, comments and user profile : These features can be implemented in the same manner as creating new objects. The same validation functions can be used.
- Single image upload : While writing blogs, users wmy want to include images in the body, so the frontend will use this route for uploading the image and get the url of the image to be displayed. This is same as uploading bannerImage but will need a separate route.