Git Product home page Git Product logo

blog_backend_api's Introduction

Blog Post Backend API

This is a backend API for managing blog posts. It is built using Node.js and Express framework, with MySQL as the database.

Features

  • User authentication: Sign up and sign in functionalities with JWT token generation and verification.
  • CRUD operations on blog posts: Create, read, update, and delete blog posts.
  • Secure endpoints: JWT token authentication middleware ensures secure access to the API endpoints.

Prerequisites

Before running this API, ensure you have the following installed:

  • Node.js and npm
  • MySQL server

Installation

  1. Clone this repository:

    git clone https://github.com/SudhanshuAi/Blog_Backend_API

  2. Install dependencies:

    npm install

  3. Set up MySQL database:

    • Install MySQL server if not already installed.

    • Start MySQL server if it's not running.

    • Access MySQL shell:

      mysql -u root -p

    • Create a MySQL database named blogpost:

      CREATE DATABASE IF NOT EXISTS blogpost;

    • Create tables by running the SQL queries provided in index.js.

    • Update the database configuration in the source code if necessary (host, user, password).

Configuration

You can configure the following settings in the config.js file:

  • JWT_SECRET: Secret key used for JWT token generation and verification.

Testing

To run tests, you need to have Mocha and Chai installed globally or as development dependencies in your project:

npm install --save-dev mocha chai

Once installed, you can run the tests with the following command:

mocha test.js

Usage

  1. Start the server:

    node index.js

API Endpoints

  • POST /api/v1/signup: User sign up with email and password.
  • POST /api/v1/signin: User sign in with email and password.
  • POST /api/v1/posts: Create a new blog post (authentication required).
  • GET /api/v1/posts/:id: Read a specific blog post.
  • PUT /api/v1/posts/:id: Update a specific blog post (authentication required).
  • DELETE /api/v1/posts/:id: Delete a specific blog post (authentication required).

Security

  • JWT token authentication is used to secure the API endpoints.

blog_backend_api's People

Contributors

sudhanshuai avatar

Watchers

 avatar

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.