Giter Site home page Giter Site logo

algo8bloggingapp's Introduction

Blogging Site Backend

This is a blogging site backend built using Express.js and MySQL with JWT authentication.

Project Structure

The project follows the following structure:

  • config/: Contains database configuration.
  • controllers/: Contains controllers for authentication and blog functionality.
  • middleware/: Contains middleware for JWT authentication.
  • models/: Contains models for User and Blog.
  • routes/: Contains route handlers for authentication and blog routes.
  • utils/: Contains utility functions like JWT generation and error handling.
  • tests/: Contains unit tests for the backend.
  • index.js: Main entry point of the application.

Setup

  1. Clone the repository:

git clone <repository-url> cd blogging-site-backend

  1. Install dependencies:

npm install

  1. Create a .env file in the root directory and define the following environment variables:
  • DB_HOST=localhost
  • DB_USER=root
  • DB_PASSWORD=password
  • DB_DATABASE=blog_db
  • JWT_SECRET=your_secret_key
  1. Set up your MySQL database according to the configurations.

  2. Start the server:

npm start

Usage

  • Register a user using /auth/register endpoint.
  • Log in using /auth/login endpoint to get a JWT token.
  • Use the obtained token for authentication in protected routes.
  • Perform CRUD operations on blogs using /blogs endpoint.

API Documentation

API documentation is available in the Swagger/OpenAPI specification file: swagger.yaml.

Start Mysql Server

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(255) UNIQUE NOT NULL,
    password VARCHAR(255) NOT NULL
);

CREATE TABLE blogs (
    id INT AUTO_INCREMENT PRIMARY KEY,
    content TEXT NOT NULL
);

algo8bloggingapp's People

Contributors

dasti-dev 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.