Skip to content

Back-end. A CRUD Blogs API with Authentication and Authorization made with Node.js, Sequelize and Express following MSC architecture.

Notifications You must be signed in to change notification settings

ibrahimborba/blogs-api

Repository files navigation

Welcome to Blogs API project!

A RESTful API that uses MSC architecture to manage a Blog's posts and users. Developed at Trybe's Back-end Module, ORM.

Summary

Context

This project is a Blogs API that uses Sequlize to connect with a MySQL database to manage posts and users. A few notable points:

  • Authentication and Authorization | Users can view and create any post as long as they're logged in. But, they can only edit and delete posts created by them.
  • Validation | User input is validated through middlewares, whilst business rules are validated in the Service layer.
  • Tests | Most of the the tests are integration, with a few unit tests for middlewares. Category routes are still to be tested, to improve test coverage.

Technologies, tools and architectures used

This project used the following technologies and tools:

Blogs API Tests and MSC architecture diagram.

Blogs API architecture

Installing and running the app

Install dependencies

cd blogs-api
npm install

Run the application without Docker

Don't forget to create and setup an .env file to connect to your local MySQL. See .env.example for avaiable variables.

cd blogs-api
npm run debug

Run the application with Docker (compose configs were developed by Trybe's team)

cd blogs-api
docker-compose up -d
docker exec -it blogs-api bash
npm install
npm run debug

Run Tests

Run all tests

npm run test

Run a specific test

NAME=<testsname> npm run test

See test coverage

npm run test:coverage

Run Lint

npm run lint

Notes

Documentation

API's documentation can be found here.

Code quality

To enforce Clean Code and good practices, the following standards and resources were used in this project:

  • Linter | Developed following the Clean Code standards specified by Trybe's ESLint.
  • SonarCloud | Passing SonarCloud's quality standards and analysis. Check the evaluation here.

Git, GitHub and Commits

Commited using the Conventional Commits specification with some types from Angular convention.