This project was built for IPSSI by Lucas Taranne & Corentin Esteve.
This project is a CRUD blog application built with NodeJS, Express, and Prisma. The application allows users to create, read, update, and delete blog posts and comments. The application also has user authentication and authorization features.
It includes the following tables in the database: User, Post and Comment. A User can have multiple Posts and Comments, and a Comment belongs to only one Post. When a Post is deleted, the Comments are deleted too.
Users can sign up and log in to view Posts, and only the author of a Post and an admin can modify it. Posts can be sorted by date through a query parameter, for example by sending a GET request to /api/posts?from=1674560065
, where the from parameter is a timestamp. Prisma is used to filter the Posts. Similarly, only the authors of Comments can modify or delete them, and an admin can also delete Comments.
The application also has a CRUD functionality for Users, only admins can delete other Users. Express-validator is used to validate requests.
The application is deployed on render.com, and the database works with PostgreSQL.
These instructions will help you access our API, connect and create posts and comments.
- A computer turned on with internet access
- A mac, because macs work better
- An API development tool such as Postman or Insomnia
To connect to the database, you will need to use your API platform, the endpoint for the app on render.com is https://ipssi-project-node-lucas-corentin.onrender.com
.
You can make requests such as GET, POST, PUT, DELETE to interact with the database. In the body of your request, you can include any necessary parameters or data needed for the specific request.
For example, to retrieve data from the database, you can make a GET request to the endpoint. To add data to the database, you can make a POST request to the endpoint with the necessary information in the request body.
POST Method
https://ipssi-project-node-lucas-corentin.onrender.com/signUp
Body
{
"username":"Pseudo",
"password":"Monsupermotdepasse"
}
POST Method
https://ipssi-project-node-lucas-corentin.onrender.com/signIn
Body
{
"username":"Pseudo",
"password":"Monsupermotdepasse"
}
DELETE Method
https://ipssi-project-node-lucas-corentin.onrender.com/api/user/:id
GET Method
https://ipssi-project-node-lucas-corentin.onrender.com/api/posts
GET Method
https://ipssi-project-node-lucas-corentin.onrender.com/api/posts/:timestamp
POST Method
https://ipssi-project-node-lucas-corentin.onrender.com/api/posts
Body
{
"title": "Hello world!",
"content": "This is my first blog post!",
"published": true
}
PUT Method
https://ipssi-project-node-lucas-corentin.onrender.com/api/posts/:id
Body
{
"title": "Hello world 0 !",
"content": "This is my first blog post 0 !",
"published": false
}
DELETE Method
https://ipssi-project-node-lucas-corentin.onrender.com/api/posts/:id
POST Method
https://ipssi-project-node-lucas-corentin.onrender.com/api/comment
{
"postId":"d863dd2f-f8fb-453e-b44f-a04b6fec0960",
"content": "This is a comment"
}
PUT Method
https://ipssi-project-node-lucas-corentin.onrender.com/api/comment/:id
Body
{
"content": "This is a comment"
}
DELETE Method
https://ipssi-project-node-lucas-corentin.onrender.com/api/comment/:id
We hope you will enjoy using our API as much as we enjoyed building it. If you have any questions or need help, please don't hesitate to reach out to us. We are always available to help.
Thank you for using our API!