A simple blog api for dummy projects
Deployed Application
·
Report Bug
·
Request Feature
A Blog has the following fields:
- path: string type (unique)
- title: string type
- content: 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
-
POST
/apiRequest body should have the fields: path, title, content, 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-blogwith 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/1with return the blog with_id = 1
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.
Cloning the repository
Creating a .env file with the same fields as mentioned in the .env.example file
Installing node packages using the command npm i.
Use the Command tsc for creating the build folder which will convert the .ts files to .js.
Running the backend server using the command npm start.