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
username
of aUser
must 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 /register
creates a new User with the provided credentials and sends a token- request body should include
username
andpassword
- the password should be hashed in the database
- request body should include
POST /login
sends a token if the provided credentials are valid- request body should include
username
andpassword
- request body should include
GET /products
sends array of all productsGET /products/:id
sends specific product- if user is logged in, then also include all orders made by the user that have this product
- 🔒
GET /orders
sends array of all orders made by the logged in user - 🔒
POST /orders
creates 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/:id
sends specific order, including all products- if the logged-in user is not the one who made the order, send a 403 Forbidden error