Ieumy is a website to order and pay food in a restaurant from a QR code, don't wait to order ! api.ieumy.com is the backend part of the App, composed of an API.
- Node JS
- postgresql
- Express
- pg (posgresql)
- bcrypt
- JsonWebToken
Clone the repository :
$ git clone ssh://[email protected]:9010/clovis/api.ieumy.com.git
Enter the repository :
$ cd api.ieumy.com
Create an image folder :
$ mkdir images
Enter the images repository :
$ cd images
Create an item directory :
$ mkdir items
Create a restaurant directory :
$ mkdir restaurants
Go back to the root of the repository :
$ cd ..
Launch the server :
$ node server
GET http://localhost:3000/api/restaurants?id=[restaurant-id]&table_nb=[table-nb]
GET http://localhost:3000/api/restaurants/my
with headers :
{
"authorization": [jwt token],
}
GET http://localhost:3000/api/restaurants/my/stripe-account
with body :
{
"restaurant": [restaurant_id],
}
and headers :
{
"authorization": [jwt token],
}
POST http://localhost:3000/api/restaurants
with body :
{
"name": "",
"description": "",
"image": [restaurant image file],
}
and headers :
{
"authorization": [jwt token],
}
PUT http://localhost:3000/api/restaurants
with body :
{
"restaurant": [resto_id],
"name": "",
"description": "",
"image": [restaurant image file] (if no image update then forget this field),
}
and headers :
{
"authorization": [jwt token],
}
PUT http://localhost:3000/api/restaurants/menu
with body :
{
"restaurant": [resto_id],
"categories": "",
}
and headers :
{
"authorization": [jwt token],
}
POST http://localhost:3000/api/restaurants/menu/category
with body :
{
"restaurant": [resto_id],
"category_name": [category_name]
}
and headers :
{
"authorization": [jwt token],
}
PUT http://localhost:3000/api/restaurants/menu/category
with body :
{
"restaurant": [resto_id],
"category_name": [category_name],
"new_category_name": [new_category_name]
}
and headers :
{
"authorization": [jwt token],
}
DELETE http://localhost:3000/api/restaurants/menu/category
with body :
{
"restaurant": [resto_id],
"category_name": [category_name]
}
and headers :
{
"authorization": [jwt token],
}
POST http://localhost:3000/api/restaurants/menu/item
with body :
{
"restaurant": [resto_id],
"category_name": [category_name],
"name": [item_name],
"description": [item_description],
"price": [item_price],
"image": [item_image (file)]
}
and headers :
{
"authorization": [jwt token],
}
PUT http://localhost:3000/api/restaurants/menu/item
with body :
{
"restaurant": [resto_id],
"category_name": [category_name],
"id": [item_id],
"name": [item_name],
"description": [item_description],
"price": [item_price],
"image": [item_image (file)] (only if update picture otherwise no image field)
}
and headers :
{
"authorization": [jwt token],
}
DELETE http://localhost:3000/api/restaurants/menu/item
with body :
{
"restaurant": [resto_id],
"category_name": [category_name],
"id": [item_id]
}
and headers :
{
"authorization": [jwt token],
}
POST http://localhost:3000/api/restaurants/menu/item/variation
with body :
{
"restaurant": [resto_id],
"category_name": [category_name],
"item_id": [item_id],
"name": [item_name],
"price_delta": [price_delta with original item]
}
and headers :
{
"authorization": [jwt token],
}
PUT http://localhost:3000/api/restaurants/menu/item/variation
with body :
{
"restaurant": [resto_id],
"category_name": [category_name],
"item_id": [item_id],
"name": [current item_name],
"new_name": [new item_name],
"price_delta": [new price_delta with original item]
}
and headers :
{
"authorization": [jwt token],
}
DELETE http://localhost:3000/api/restaurants/menu/item/variation
with body :
{
"restaurant": [resto_id],
"category_name": [category_name],
"item_id": [item_id],
"name": [item_name],
}
and headers :
{
"authorization": [jwt token],
}
POST http://localhost:3000/api/owners
with body :
{
"email": "",
"firstname": "",
"lastname": "",
"password": ""
}
GET http://localhost:3000/api/owners/confirm-account?token=[token]
POST http://localhost:3000/api/owners/login
with body :
{
"email": "",
"password": ""
}
PUT http://localhost:3000/api/owners
with body :
{
"firstname": "",
"lastname": "",
}
and headers :
{
"authorization": [jwt token],
}
PUT http://localhost:3000/api/owners/password
with body :
{
"email": "",
"password": "",
"new_password": [new_password]
}
PUT http://localhost:3000/api/owners/email
with body :
{
"new_email": [new_email_address]
}
and headers :
{
"authorization": [jwt token],
}
GET http://localhost:3000/api/owners/confirm-email?token=[token]
Also delete restaurant, orders and subcriptions
DELETE http://localhost:3000/api/owners
with headers :
{
"authorization": [jwt token],
}
POST http://localhost:3000/api/customers
with body :
{
"email": "",
"firstname": "",
"lastname": "",
"password": "",
"address": ""
}
GET http://localhost:3000/api/customers/confirm-account?token=[token]
POST http://localhost:3000/api/customers/login
with body :
{
"email": "",
"password": ""
}
PUT http://localhost:3000/api/customers
with body :
{
"firstname": "",
"lastname": "",
"address": ""
}
and headers :
{
"authorization": [jwt token],
}
PUT http://localhost:3000/api/customers/password
with body :
{
"email": "",
"password": "",
"new_password": ""
}
PUT http://localhost:3000/api/customers/email
with body :
{
"new_email": [new_email]
}
and headers :
{
"authorization": [jwt token]
}
GET http://localhost:3000/api/customers/confirm-email?token=[token]
DELETE http://localhost:3000/api/customers
with headers :
{
"authorization": [jwt token]
}
an order status is either : "pending", "payed", "served" or "cancelled" when order is served or cancelled, it is not possible to update is anymore and a end_time is given. An order will never be visible by the restaurant owner as long as the order is not at least payed. The pending status is only visible for the backend to handle the payment processing. An order that not payed within an hour is automatically deleted from the database.
POST http://localhost:3000/api/orders
with body :
{
"lastname": "", //only for logged out customers
"firstname": "", //only for logged out customers
"email": "", //only for logged out customers
"items": [item],
"resto_id": [restaurant_id],
"table_nb": [table_nb]
}
and headers (optional: only for logged in customers) :
{
"authorization": [jwt token],
}
item example (without variation) :
{
"id": 0,
"name": "Oeuf mimosa",
"variation": null,
"price": 4,
"qty": 11
}
item example (with variation) :
{
"id": 7,
"name": "Choux chantilly",
"description": "magnifique choux chantilly préparé par un vrai chef",
"variation": {
"name": "nappage choco",
"price_delta": 0.5
},
"qty": 1
}
GET http://localhost:3000/api/orders/my
with body :
{
"restaurant": [restaurant_id],
"id": [order_id]
}
GET http://localhost:3000/api/orders
with body :
{
"restaurant": [restaurant_id]
}
and headers :
{
"authorization": [jwt token],
}
GET http://localhost:3000/api/orders/payed
with body :
{
"restaurant": [restaurant_id]
}
and headers :
{
"authorization": [jwt token],
}
PUT http://localhost:3000/api/orders/update/served
with body :
{
"restaurant": [restaurant_id],
"order_id": ""
}
and headers :
{
"authorization": [jwt token],
}
PUT http://localhost:3000/api/orders/update/cancelled
with body :
{
"restaurant": [restaurant_id],
"order_id": ""
}
and headers :
{
"authorization": [jwt token],
}
GET http://localhost:3000/api/subscriptions/current
with body :
{
"restaurant": [restaurant_id]
}
and headers :
{
"authorization": [jwt token],
}
POST http://localhost:3000/api/subscriptions/new
with body :
{
"restaurant": [restaurant_id],
"table_amount": [number of tables in subscription]
}
and headers :
{
"authorization": [jwt token],
}
GET http://localhost:3000/api/subscriptions/manage-link
with headers :
{
"authorization": [jwt token],
}
Update Payment status (to payed or failed) : if payed then updates in database and becomes visible for restaurant owner otherwise if failed then the order is deleted from the database
POST http://localhost:3000/api/webhooks/stripe/payment-status
Update Subscription Payment status (to pending or payed): if payed then subscription becomes active for 30 days, otherwise subscription is not active. Renew Subscription when paid: when triggered take last active subscription of owner and renew it for 30 days. Send Email to owner when subscription payment failed and warn that after the deadline, service won't be provided anymore
POST http://localhost:3000/api/webhooks/stripe/subscription-status