Blog API
A simple blog api for dummy projects
Deployed Application
·
Report Bug
·
Request Feature
Schema
A Blog has the following fields:
- path: string type (unique)
- title: string type
- html: string type
- author: string type
- tag: string type
- img: file type [jpg, png, jpeg]
- author_icon: file type [jpg, png, jpeg]
- createdAt: date type (automatically calculated in the backend)
- _id: mongo object id
Endpoints
-
POST
/api
Request body should have the fields: path, title, html, author, tag, img, author_icon -
GET /api?limit=50&offset=0 By passing limit and offset in the url, you can control how many blogs to return. If no params are passed, 10 blogs are returned by default.
-
GET /api/path/{path} Fetches a blog with the given path. For example, a GET request on
api/path/test-blog
with return the blog withpath = test-blog
-
GET /api/id/{id} Fetches a blog with the given object id. For example, a GET request on
api/id/1
with return the blog with_id = 1
Running the server locally
The first 3 steps below are to set the project up in your local environment, which is to be done just once at the beggining.
STEP 1:
Cloning the repository
STEP 2:
Creating a .env file with the same fields as mentioned in the .env.example
file
STEP 3:
Installing node packages using the command npm i
STEP 4:
Running the backend server using the command npm start
.