Giter Site home page Giter Site logo

sahilll15 / blogging-platform-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 30 KB

A RESTful API built with Node.js, Express.js, and MySQL for managing blog posts, comments, and user authentication. Features user registration, login/logout, CRUD operations for posts and comments, and middleware for authentication/error handling.

JavaScript 100.00%

blogging-platform-api's Introduction

Blogging Platform API -MYSQL BACKEND

This repository contains the RESTful API for a blogging platform built using Express.js and MySQL. The API supports operations related to blog posts, comments, and user authentication.

Features

  • User authentication using JSON Web Tokens (JWT)
  • CRUD operations for blog posts
  • CRUD operations for comments
  • Middleware for authentication and error handling
  • Input data validation
  • Use of a relational database (MySQL) for data storage

Requirements

  • Node.js
  • MySQL

Installation

  1. Clone the repository:

     git clone https://github.com/sahilll15/blogging-platform-api.git
  2. Go into the working directory

cd blogging-platform-api
  1. view the .env.example file and add the required fields

  2. run the project

npm i
nodemon index.js

API Documentation

the APIs of the project are

  1. Authentication API

    • POST auth/register: Register a new user.
    • POST auth/login: Log in an existing user.
  2. Blog Posts API

    • POST /blog/create: Create a new blog post.
    • GET /blog/all: Get all blog posts.
    • GET /blog/get/:id: Get a single blog post by ID.
    • PUT /blog/update/:id: Update a blog post by ID.
    • DELETE /blog/delete/:id: Delete a blog post by ID.
  3. Comments API

    • POST /comment/create/:postId: Create a new comment.
    • GET /comment/get/:postId: Get all comments for a post.
    • PUT /comment/update/:commentId: Update a comment by ID.
    • DELETE /comment/delete/:commentId: Delete a comment by ID.
    • GET /comment/comment/:commentId: get the comment by the comment id
  4. Middleware - Authentication middleware: Ensures that only authenticated users can access certain routes. - Error handling middleware: Handles errors and returns appropriate HTTP responses.

  5. Database Connection

    • The API uses MySQL as the database management system.
    • The database connection details can be configured in the db.js file.

Tech Stack

Server: Node, Express,mysql2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.