Giter Site home page Giter Site logo

blogging-platform's Introduction

Blogging-Platform

video.mov

This repository contains the source code for a Blogging Platform built using the PERN (PostgreSQL, Express.js, React, Node.js) stack. The platform allows users to register, create posts, add comments, and perform various CRUD (Create, Read, Update, Delete) operations on posts and comments.

Table of Contents

Database Setup and Relationships

To set up the database, follow these steps:

  1. Install PostgreSQL on your system.
  2. Create a new PostgreSQL database for the blogging platform.
  3. Update the database credentials in the configuration file (config/config.js) with your PostgreSQL connection details.
  4. Run the Sequelize migrations to generate the necessary tables and relationships.

User Registration and Login

The platform provides user registration and login functionality with hashed passwords. To register and login:

  1. Use the provided API endpoints to register a new user and obtain an authentication token.
  2. Authenticate the user by sending the token in the request headers.
  3. Use the token to create a session cookie upon successful login.

User Authentication and Authorization

To protect routes that require authentication:

  1. Implement middleware functions to validate the session cookie and ensure user authentication.
  2. Apply the middleware to the appropriate routes.
  3. Test the authentication and authorization flow using Postman, ensuring only authenticated users can access protected routes.

CRUD Operations for Posts

The platform supports CRUD operations for posts. Use the provided API endpoints to:

  • Create a new post
  • Retrieve all posts
  • Retrieve a specific post by ID
  • Update a post
  • Delete a post

Ensure that only authenticated users can perform these operations on posts.

CRUD Operations for Comments

The platform supports CRUD operations for comments. Use the provided API endpoints to:

  • Create a new comment
  • Retrieve all comments for a specific post
  • Retrieve a specific comment by ID
  • Update a comment
  • Delete a comment

Ensure that only authenticated users can perform these operations on comments.

Installation

To run the Blogging Platform locally, follow these steps:

  1. Clone this repository: git clone https://github.com/VitaliPri/Blogging-Platform.git
  2. Navigate to the project directory: cd Blogging-Platform
  3. Install the dependencies for the backend server: cd server && npm install
  4. Install the dependencies for the frontend client: cd ../client && npm install
  5. Configure the database connection in server/config/config.json
  6. Run the database migrations: cd ../server && npx sequelize-cli db:migrate

Usage

To start the Blogging Platform, follow these steps:

  1. Start the backend server: cd server && npm start
  2. In a separate terminal, start the frontend client: cd ../client && npm start
  3. Open your browser and navigate to http://localhost:4000 to access the Blogging Platform.

API Endpoints

The API endpoints provided by the server are as follows:

  • POST /api/users/register: Register a new user.
  • POST /api/users/login: Login a user and obtain an authentication token.
  • GET /api/posts: Retrieve all posts.
  • GET /api/posts/:id: Retrieve a specific post by ID.
  • POST /api/posts: Create a new post.
  • PUT /api/posts/:id: Update a post.
  • DELETE /api/posts/:id: Delete a post.
  • GET /api/posts/:id/comments: Retrieve all comments for a specific post.
  • GET /api/comments/:id: Retrieve a specific comment by ID.
  • POST /api/comments: Create a new comment.
  • PUT /api/comments/:id: Update a comment.
  • DELETE /api/comments/:id: Delete a comment.

Please refer to the API documentation for more details on request and response formats.

Testing

The platform can be tested using Postman or other API testing tools. The provided API endpoints should be used to perform various operations on users, posts, and comments. Ensure that you test the authentication and authorization flow as well.

Contributing

Contributions to the Blogging Platform are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request. Contributions should align with the project's coding style and follow the guidelines specified in the repository.

blogging-platform's People

Contributors

craftingweb avatar

Stargazers

 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.