Skip to content

This project is a blog website & it's backend is a REST API developed using nodejs. This is one of my personal projects. This repo holds the backend code of the project.

Notifications You must be signed in to change notification settings

tazbin/blog-website-backend-nodejs-REST-API

Repository files navigation

blog-website-backend-nodejs-REST-API

blog-website is one of my personal projects where registered bloggers write blogs. Bloggers can also comment or react to blogs. This repository holds the code of it's backend which is a RESTful API.

The frontend of this project can be found here (Angular)

Visit complete live project lets-blog.netlify.app/all_blogs

Contents

Features:

  • bloggers can create their profiles (token-based authentication)
  • bloggers can edit their profile
  • bloggers can write blogs. They can set the category of their blog (i.e. travel, medical, tech etc)
  • registered bloggers can comment on their own or others blog
  • registered bloggers can also react on others blog. They can react like, love, sad, haha, informative to blogs
  • unregistered public users can read blogs but can't comment or react n blogs
  • Blogs of a particular category can be viewed

Tech used:

Runtime environment

  • Node.js

Database

  • MongoDB

Image storage service

  • Cloudinary

Testing framework

  • Jest

Containerization tool

  • Docker

How to get the project:

Using Git (recommended)

  1. Navigate & open CLI into the directory where you want to put this project & Clone this project using this command.
git clone https://github.com/tazbin/blog-website-backend-nodejs-REST-API.git

Using manual download ZIP

  1. Download repository
  2. Extract the zip file, navigate into it & copy the folder to your desired directory

Setting up environments

  1. There is a file named .env.example on the root directory of the project
  2. Create a new file by copying & pasting the file on the root directory & rename it to just .env
  3. The .env file is already ignored, so your credentials inside it won't be committed
  4. Change the values of the file. Make changes of comment to the .env.example file while adding new constants to the .env file.

Run the project using docker

  1. To build docker image

    docker compose build --no-cache
  2. To run the containers in detached mode (wait for a while for database connection)

    docker compose up -d
  3. To view running containers

    docker container ps
  4. To view API logs

    docker logs letsblog-api-c
  5. To run tests, first enter within the API container

    • on windows CMD (not switching to bash)
      docker exec -it letsblog-api-c /bin/sh
    • on windows CMD (after switching to bash)
      docker exec -it letsblog-api-c //bin//sh
      or
      winpty docker exec -it letsblog-api-c //bin//sh

    now run test command

    npm test
  6. To exit from API container, press Ctrl+D on terminal

  7. To stop the containers

    docker compose down

API endpoints:

Indication

  • Authentication required
  • Authentication not required

User related

Category related

Blog related

About

This project is a blog website & it's backend is a REST API developed using nodejs. This is one of my personal projects. This repo holds the backend code of the project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages