NodeJS server for taking care of Slice Life Pizzeria's deliveries.
The following routes are available:
Route | Description |
---|---|
api/users |
CRUD operations to manage users |
api/tokens |
CRUD operations to manage tokens |
/api/menu |
GET route to view the menu |
/api/cart |
View or empty cart and add or remove a menu item |
/api/order |
POST route to create an order, process payment through Stripe and email a confirmation |
When no route is found a 404
status will be returned.
-
Clone or download this project
-
Rename
example.config.js
toconfig.js
-
Register for Stripe and Mailgun and populate their API keys and details into the config file.
-
Run
node index.js
to start the server -
Optional: Run the server under SSL.
Create a SSL certificate in the https directory. (You can use the below command)
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
- Create a user
POST /api/users
- Log in by creating a token
POST /api/tokens
- Request for the menu
GET /api/menu?email=<email>
- Add one or several item(s) to the cart
POST /api/cart
- Review items in the cart
GET /api/cart?email=<email>
- Create an order
POST /api/order
For exact API details import Slice Life Pizzeria into Postman and follow the steps in the above paragraph.
After a successfull transaction an order confirmation is sent to the user's email address, which looks like the below.
NOTE: When using Mailgun in Sandbox mode, only authorized recipients receive an email. If this is the case, make sure the email address in the to: field is authorized.
When debugging of the server is required use the following syntax when starting the server for additional information.
iOS: NODE_DEBUG=[option] node index.js
*
Windows: set NODE_DEBUG=[option]&&node index.js
*
The following options are available:
- server
* replace [option]
with one of the above.
iOS: NODE_ENV=production node index.js
Windows: set NODE_ENV=production node index.js