Giter VIP home page Giter VIP logo

api's Introduction

Our CRUD Blog Application

Authors

This project was built for IPSSI by Lucas Taranne & Corentin Esteve.

Overview

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.

Getting Started

These instructions will help you access our API, connect and create posts and comments.

Prerequisites

  • A computer turned on with internet access
  • A mac, because macs work better
  • An API development tool such as Postman or Insomnia

Connecting to database

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.

Application Routes

User Routes

Create a new user

POST Method

  https://ipssi-project-node-lucas-corentin.onrender.com/signUp

Body

{
  "username":"Pseudo",
  "password":"Monsupermotdepasse"
}

Log in an existing user

POST Method

  https://ipssi-project-node-lucas-corentin.onrender.com/signIn

Body

{
  "username":"Pseudo",
  "password":"Monsupermotdepasse"
}

Delete an existing user (only for admin users)

DELETE Method

  https://ipssi-project-node-lucas-corentin.onrender.com/api/user/:id

Post Routes

Get all blog posts

GET Method

  https://ipssi-project-node-lucas-corentin.onrender.com/api/posts

Get all blog posts created after a specific timestamp

GET Method

  https://ipssi-project-node-lucas-corentin.onrender.com/api/posts/:timestamp

Create a new blog post

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
}

Update a specific post

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 a specific post

DELETE Method

https://ipssi-project-node-lucas-corentin.onrender.com/api/posts/:id

Comment Routes

Create a new comment

POST Method

https://ipssi-project-node-lucas-corentin.onrender.com/api/comment
{
"postId":"d863dd2f-f8fb-453e-b44f-a04b6fec0960", 
"content": "This is a comment" 
}

Update an existing comment

PUT Method

https://ipssi-project-node-lucas-corentin.onrender.com/api/comment/:id

Body

{
"content": "This is a comment" 
}

Delete an existing comment

DELETE Method

https://ipssi-project-node-lucas-corentin.onrender.com/api/comment/:id

Conclusion

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!

api's People

Contributors

lulu960 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.