Delivery API

This delivery API was built with Nodejs, Typescript and MongoDB. All routes for this api begin with https://delivery-api-l1dp.onrender.com
githubportfolio

Session Routes - /api/sessions

These routes handle the logging in and loggin out of users. The username and password is checked to ensure it matches what is present in the database, then an access token and refresh token is returned to the browser allowing the user to access restricted routes in the application. Some routes also require admin authorization. These routes can be identified when a 403 error is thown. To overcome this, please login the following admin user: {email: alejandrogarnacho@email.com, password: password}

post

Login user
Login a user by sending a post request to the session endpoint - /api/sessions

{"accessToken":"","refreshToken":""}

User Routes - /api/users

These routes handle everything user related. However, some of the routes are restricted to admin users only, and all routes need a user to be signed in before then can be used. You can start by creating a user, then heading to the sessions route and logging the user in before continuing with the rest of the app.

POST

create user
Create a user by sending a post request to the endpoint - /api/users

{"passwordConfirmation":"","profile":{"address":{"street1":"","street2":"","city":"","state":"","country":"","zip":""},"firstName":"","lastName":"","avatar":"","bio":""},"_id":"","username":"","email":{"address":"","validated":true,"_id":""},"password":"","active":true,"isAdmin":false,"createdAt":"","updatedAt":"","__v":0}

GET

Get users
Get all users by sending a get request to the endpoint - /api/users

[{"passwordConfirmation":"","profile":{"address":{"street1":"","street2":"","city":"","state":"","country":"","zip":""},"firstName":"","lastName":"","avatar":"","bio":""},"_id":"","username":"","email":{"address":"","validated":true,"_id":""},"password":"","active":true,"isAdmin":false,"createdAt":"","updatedAt":"","__v":0}]

GET

Get user
Get a user by sending a get request to the endpoint - /api/users/:id

{"passwordConfirmation":"","profile":{"address":{"street1":"","street2":"","city":"","state":"","country":"","zip":""},"firstName":"","lastName":"","avatar":"","bio":""},"_id":"","username":"","email":{"address":"","validated":true,"_id":""},"password":"","active":true,"isAdmin":false,"createdAt":"","updatedAt":"","__v":0}

Patch

Update User
Update a user by sending a patch request and data to the endpoint - /api/users/:id

{"passwordConfirmation":"","profile":{"address":{"street1":"","street2":"","city":"","state":"","country":"","zip":""},"firstName":"","lastName":"","avatar":"","bio":""},"_id":"","username":"","email":{"address":"","validated":true,"_id":""},"password":"","active":true,"isAdmin":false,"createdAt":"","updatedAt":"","__v":0}

Delete

Delete user
Delete a user by sending a delete request to the endpoint - /api/users

{"passwordConfirmation":"","profile":{"address":{"street1":"","street2":"","city":"","state":"","country":"","zip":""},"firstName":"","lastName":"","avatar":"","bio":""},"_id":"","username":"","email":{"address":"","validated":true,"_id":""},"password":"","active":true,"isAdmin":false,"createdAt":"","updatedAt":"","__v":0}

Product Routes - /api/products

These routes are protected routes, and so a user needs to be logged in before you are able to access them. They handle the creation, fecthing, updating, and deleting of products.

post

Create Product
Create a product by sending a post request and some data to the endpoint - /api/products

{"_id":"","user":"","title":"","desc":"","price":0,"image":"","id":"","createdAt":"","updatedAt":"","__v":0}

GET

Get Products
Get all products by sending a get request to the endpoint - /api/products

[{"_id":"","user":"","title":"","desc":"","price":0,"image":"","id":"","createdAt":"","updatedAt":"","__v":0}]

GET

Get product
Get a product by sending a get request to the endpoint - /api/products

{"_id":"","user":"","title":"","desc":"","price":0,"image":"","id":"","createdAt":"","updatedAt":"","__v":0}

Patch

Update product
Update a product by sending a patch request and data to the endpoint - /api/products

{"_id":"","user":"","title":"","desc":"","price":0,"image":"","id":"","createdAt":"","updatedAt":"","__v":0}

Delete

Delete product
Delete a product by sending a delete request to the endpoint - /api/products

{"_id":"","user":"","title":"","desc":"","price":0,"image":"","id":"","createdAt":"","updatedAt":"","__v":0}

Cart Routes - /api/carts

These routes handle everything cart related. However, some of the routes are restricted to admin users only, and all routes need a user to be signed in before then can be used. You can create a cart, update a cart (add products to cart), and delete a cart. All items added to the cart need to be already existing products. Here is one: product_73872ef3-e4bc-4659-868d-2562e42d9bae

post

Create Cart
Create a cart by sending a post request and some data to the endpoint - /api/carts

{"_id":"","userId":"","products":[{"product_id":"","quantity":0,"title":"","price":0,"_id":""}],"active":true,"id":"","modifiedOn":"","createdAt":"","updatedAt":"","__v":0}

GET

Get carts
Get all carts by sending a get request to the endpoint - /api/carts

[{"_id":"","userId":"","products":[{"product_id":"","quantity":0,"title":"","price":0,"_id":""}],"active":true,"id":"","modifiedOn":"","createdAt":"","updatedAt":"","__v":0}]

GET

Get cart
Get a cart by sending a get request to the endpoint - /api/carts

{"_id":"","userId":"","products":[{"product_id":"","quantity":0,"title":"","price":0,"_id":""}],"active":true,"id":"","modifiedOn":"","createdAt":"","updatedAt":"","__v":0}

Patch

Update cart
Update a cart by sending a patch request and data to the endpoint - /api/carts

{"_id":"","userId":"","products":[{"product_id":"","quantity":0,"title":"","price":0,"_id":""}],"active":true,"id":"","modifiedOn":"","createdAt":"","updatedAt":"","__v":0}

Delete

Delete cart
Delete a cart by sending a delete request to the endpoint - /api/carts

{"_id":"","userId":"","products":[{"product_id":"","quantity":0,"title":"","price":0,"_id":""}],"active":true,"id":"","modifiedOn":"","createdAt":"","updatedAt":"","__v":0}

Order Routes - /api/orders

These routes handle everything order related. However, some of the routes are restricted to admin users only, and all routes need a user to be signed in before then can be used. You can create a order, update an order (mark as completed, or incomplete), and delete an order.

post

Create Order
Create an order by sending a post request and some data to the endpoint - /api/orders

{"_id":"","user":"","cart":"","isCompleted":false,"id":"","createdAt":"","updatedAt":"","__v":0}

GET

Get orders
Get all orders by sending a get request to the endpoint - /api/orders

[{"_id":"","user":"","cart":"","isCompleted":false,"id":"","createdAt":"","updatedAt":"","__v":0}]

GET

Get order
Get a order by sending a get request to the endpoint - /api/orders

{"_id":"","user":"","cart":"","isCompleted":false,"id":"","createdAt":"","updatedAt":"","__v":0}

Patch

Update order
Update a order by sending a patch request and data to the endpoint - /api/orders

{"_id":"","user":"","cart":"","isCompleted":false,"id":"","createdAt":"","updatedAt":"","__v":0}

Delete

Delete order
Delete a order by sending a delete request to the endpoint - /api/orders

{"_id":"","user":"","cart":"","isCompleted":false,"id":"","createdAt":"","updatedAt":"","__v":0}