Market is our latest e-commerce platform that will allow users to browse and purchase a wide selection of products.
textual representation of the database schema in DBML
- Create a new Postgres database named
market. - Initialize Prisma and connect it to the database.
- Define the models according to the schema above.
- The
usernameof aUsermust be unique.
- The
- Seed the database with at least 20 products.
Build an Express app that serves the following routes.
The 🔒 lock icon next to a route indicates that it must be a protected route. A user can only access that route by attaching a valid token to their request. If a valid token is not provided, immediately send a 401 Unauthorized error.
POST /registercreates a new User with the provided credentials and sends a token- request body should include
usernameandpassword - the password should be hashed in the database
- request body should include
POST /loginsends a token if the provided credentials are valid- request body should include
usernameandpassword
- request body should include
GET /productssends array of all productsGET /products/:idsends specific product- if user is logged in, then also include all orders made by the user that have this product
- 🔒
GET /orderssends array of all orders made by the logged in user - 🔒
POST /orderscreates a new order by the logged in user- the request body should include the
date, anote, and ids of the products to purchase
- the request body should include the
- 🔒
GET /orders/:idsends specific order, including all products- if the logged-in user is not the one who made the order, send a 403 Forbidden error