In the Blogs-API Project, we had to develop a RESTful API to handle CRUD (Create, Read, Update, Delete) actions in the context of a blogging site. The application was built on an MSC (Models, Services and Controllers) architecture to ensure more organisation and security. The site users can create and delete accounts in order to create, edit and delete blog posts and post categories.
Overall, the application was made using Node.js and Express.Js. To handle the database (and structure it with migrations), we built the model layer using Sequelize (ORM tool), which facilitates future changes to the code or database.
As users can only change the data referring to their own blog, we used JWT (token validation) both for creating/deleting accounts and for creating/editing/deleting new blog posts and post categories.
Node.js
Express.js
JSON Web Token (JWT)
Sequelize
MySQL
After cloning the repository, you need to install the necessary dependencies with the npm install
command and start the project with the npm start
command. You can create the database with npm run prestart
or drop it with npm run drop
. To populate its tables, use npm run seed
. After that, you can make requests to the API using an HTTP client (Insomnia, Postman, HTTPie, etc.).
Endpoint for Login
- post('/');
Endpoints for Users
- post('/');
- get('/');
- get('/:id');
- delete('/me');
Endpoints for Blog Posts
- post('/');
- get('/search');
- get('/');
- get('/:id');
- put('/:id');
- delete('/:id');
Endpoints for Categories
- post('/');
- get('/');
You can check the entire commit history to see how the project was developed step by step. All commits were based on the Conventional Commits guide, keeping an organization and accurate description of what was done with each change.
You can get in touch with me at pedronerislc@gmail.com or by Linkedin.