REST API that gets information from MongoDB cloud storage for e-commerce web applications. It is used in the Simmer Eats project. It currently offers 3 different authorization levels: Basic Authentication, Business Authentication, and Admin Authentication.
- Local Development Mode
# clone the repository
git clone https://github.com/raquel-f/simmer-eats-API.git
# install dependencies
npm install
- Setup Environment Variables
# Mongo DB username
DB_USER=...
# Mongo DB password
DB_PASSWORD=...
# JSON Web Token Secret
JWT_SECRET=...
# Stripe Secret Key for payment integration
STRIPE_SECRET=...
# Stripe Secret Key for webhook events
STRIPE_WEBHOOK_SECRET=...
- Run the project
# run the project
npm start
-
Usage
Connect to the API using Postman on port 5000.
-
Open the source code
The project auto-updates as you edit the files thanks to Nodemon. Don't forget to save the changes!
A quick look at the top-level files and directories you'll see in this project.
.
├── constants
├── controllers
├── docs
├── middleware
├── models
├── node_modules
├── routes
├── uploads
├── .env
├── .gitignore
├── index.js
├── package-lock.json
├── README.md
└── vercel.json
HTTP Method | Authentication | Endpoint | Action |
---|---|---|---|
GET |
None | /food | Retrieve all food items |
GET |
None | /food/:id | Retrieve details of a single food item |
GET |
Admin | /user/:id | Retrieve details of a single user account |
GET |
Basic | /user/me | Retrieve details of the authenticated user's account |
POST |
None | /user/signup | Create a new user account |
POST |
None | /user/signin | Login with an existing user account |
PATCH |
Basic | /user/me | Update details of the authenticated user's account |
DELETE |
Basic | /user/me | Delete the authenticated user's account |
GET |
None | /image/:id | Retrieve details of a single image |
POST |
Business | /image | Create a new image |
GET |
Basic | /cart/me | Retrieve details of the authenticated user's shopping cart |
POST |
Basic | /stripe/createCheckout | Create a new Stripe payment checkout session |
POST |
None | /webhook | Handle Stripe webhook events |
GET |
Basic | /delivery/me | Retrieve details of the authenticated user's deliveries |