/IBlog

Primary LanguageTypeScript

Blogging System

Description

This project is a blogging system developed using TypeScript, Express, and Mongoose. It features user authentication, blog creation, and comment posting functionalities.

Table of Content

  1. Installation
  2. Usage
  3. API Documentation

Installation

Prerequisites

  • Node.js
  • MongoDB

Steps

  1. Clone the repository
  2. git clone https://github.com/Darkeh1807/IBlog.git

    cd IBlog

  3. Install Dependencies
  4. npm install

  5. Create a '.env' file in the root directory and add the following
  6. PORT = PORT NUMBER

    MONGOURL = your_mongodb_connection_string

    JWTSECRET = your_jwt_secret

  7. Build the project
  8. npm run build

  9. Start server
  10. npm run start

Usage

Running in development mode

npm run dev

Building the project

npm run build

Starting the server

npm start

API Documentation

User Routes
Register a User
  • URL: '/api/users/register'
  • Method: 'POST'
  • Request Body
  • { "name": "John Doe", "email": "johndoe@example.com", "password": "yourpassword", "role": "ADMIN" }

    NB: If no role is specified, Defaults to 'USER'

Log in a User
  • URL: '/api/users/login'
  • Method: 'POST'
  • Request Body
  • { "email": "johndoe@example.com", "password": "yourpassword" }
Blog Routes
Create Blog(Admin)
  • URL: '/api/users/blog'
  • Method: 'POST'
  • Request Body
  • { "title": "Example blog title", "description": "Example blog content ", "createdBy": "admin ID", }