singhayushh / blog-api

Simple Blog API for dummy projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blog API

A simple blog api for dummy projects
Deployed Application · Report Bug · Request Feature

Schema

A Blog has the following fields:

  1. path: string type (unique)
  2. title: string type
  3. html: string type
  4. author: string type
  5. tag: string type
  6. img: file type [jpg, png, jpeg]
  7. author_icon: file type [jpg, png, jpeg]
  8. createdAt: date type (automatically calculated in the backend)
  9. _id: mongo object id

Endpoints

  1. POST /api Request body should have the fields: path, title, html, author, tag, img, author_icon

  2. 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.

  3. 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 with path = test-blog

  4. 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.

About

Simple Blog API for dummy projects


Languages

Language:TypeScript 98.9%Language:Shell 1.1%