This is a simple rest api allowing to book tickets for a event.
- dev.env:
PORT=3000
MONGODB_URI=mongodb://127.0.0.1:27017/monte-tickets
UNIFIED_TOPOLOGY=false
AUTO_RECONNECT=true
DEV=true
- test.env:
PORT=3000
MONGODB_URI=mongodb://127.0.0.1:27017/monte-tickets-test
UNIFIED_TOPOLOGY=false
AUTO_RECONNECT=true
here we are swaping unified_topology and auto_reconnect to make it work in docker (it is a little hack as autoReconnect option for mongoose will be soon deprecated and we will have to implement our own reconnect mechanism)
- dc.env:
PORT=3000
MONGODB_URI=mongodb://mongo:27017/monte-tickets-docker
UNIFIED_TOPOLOGY=true
AUTO_RECONNECT=false
npm install
npm run dev
npm run test
docker-compose up --build
docker build -t <TAG_NAME> .
docker run -p80:3000 <TAG_NAME>
The REST API endpoints are described below.
POST /reservations
{"eventId":"<id>","sellingOption":2, "seats": { "B": [5, 6] } }
"reservation": {
"isPaid": false,
"_id": "60d2107674c3cd19b78d5852",
"sellingOption": 2,
"ticketQuantity": 2,
"totalAmount": 60
}
POST /payment
{"reservationId":"60d2107674c3cd19b78d5852","token":"" }
{
"_id": "60d2107d74c3cd19b78d5857",
"reservation": "60d2107674c3cd19b78d5852",
"createdAt": "2021-06-22T16:31:57.085Z",
"updatedAt": "2021-06-22T16:31:57.085Z",
"__v": 0
}