-
Download MongoDB.
-
Download Node.js.
-
Clone or pull repository.
-
Download mongosh (optional).
-
Run
npm install
in root directory of the project. -
Run
Node app.js
. -
You can also use Nodemon instead of Node for life-reloads on changes. You need to install it globally using npm.
-
Setup .env file. There is
.env example
file for guiding this process.
http://localhost:3001
Public healthcheck to test application
Response 200 (JSON)
{
"message": "Events API is working correctly"
}
Register
Request body
{
"username": USERNAME,
"password": PASSWORD
}
Response 201 example (JSON)
{
"id": "663c5e2fa3708a9482fd87d5",
"username": "User",
"secret": "dXlLCZFIVf"
}
Login
Request body
{
"username": USERNAME, // string
"password": PASSWORD // string
}
Response 200 example (JSON)
{
"id": "663c5e2fa3708a9482fd87d5",
"username": "User",
"secret": "dXlLCZFIVf"
}
Private healthcheck to check credentials manager
Request body
{
"username": USERNAME, // string
"secret": SECRET // string
}
Response 200 (JSON)
{
"message": "Events API credentials middleware is working correctly"
}
Creating event, for internal purpose only
Request body
{
"name": NAME, // string
"type": TYPE, // string, must be 'concert', 'sport' or 'exhibition'
"location": LOCATION, // string
"date": DATE, // string
"price": PRICE // number
}
Response 201 (JSON)
{
"name": "Weissnat, Greenfelder and Pacocha",
"type": "sport",
"price": 1337,
"location": "419 Walsh Brooks",
"date": "2024-11-02T20:50:08.000Z",
"image": BASE64 // large base64 string
}
Getting all events
Response 200 example (JSON)
{
"events": [
{
"defaultImage": {
"data": {
"type":"Buffer","data": [BYTE ARRAY]
}
},
"_id": "663c5d5ca3708a9482fd87d2",
"hasImage": false,
"name": "Weissnat, Greenfelder and Pacocha",
"type": "sport",
"location": "419 Walsh Brooks","date":"2024-11-02T20:50:08.000Z",
"price": 1337,
"__v": 0
}
]
}
Getting sport events
Response 200 example (JSON)
{
"events": [
{
"defaultImage": {
"data": {
"type":"Buffer","data": [BYTE ARRAY]
}
},
"_id": "663c5d5ca3708a9482fd87d2",
"hasImage": false,
"name": "Weissnat, Greenfelder and Pacocha",
"type": "sport",
"location": "419 Walsh Brooks","date":"2024-11-02T20:50:08.000Z",
"price": 1337,
"__v": 0
}
]
}
Getting concert events
Response 200 example (JSON)
{
"events": [
{
"defaultImage": {
"data": {
"type":"Buffer","data": [BYTE ARRAY]
}
},
"_id": "663c5d5ca3708a9482fd87d2",
"hasImage": false,
"name": "Weissnat, Greenfelder and Pacocha",
"type": "sport",
"location": "419 Walsh Brooks","date":"2024-11-02T20:50:08.000Z",
"price": 1337,
"__v": 0
}
]
}
Getting exhibition events
Response 200 example (JSON)
{
"events": [
{
"defaultImage": {
"data": {
"type":"Buffer","data": [BYTE ARRAY]
}
},
"_id": "663c5d5ca3708a9482fd87d2",
"hasImage": false,
"name": "Weissnat, Greenfelder and Pacocha",
"type": "sport",
"location": "419 Walsh Brooks","date":"2024-11-02T20:50:08.000Z",
"price": 1337,
"__v": 0
}
]
}
Creating ticket for certain event
Request body
{
"quantity": QUANTITY, // number
"price": PRICE, // number
"username": USERNAME, // string
"secret": SECRET // string
}
Response 201 example (JSON)
{
"quantity": 1,
"price": 4,
"isArchived": false,
"event": [
"663bd29bd2d1a07681577ca9"
],
"user": [
"663c5e2fa3708a9482fd87d5"
],
"_id": "663c5fe2a3708a9482fd87dd",
"__v": 0
}
Getting user's all tickets
Request body
{
"username": USERNAME, // string
"secret": SECRET // string
}
Response 200 example (JSON)
[
{
"_id": "663c5fe2a3708a9482fd87dd",
"quantity": 1,
"price": 4,
"isArchived": false,
"event": [
"663bd29bd2d1a07681577ca9"
],
"user": [
"663c5e2fa3708a9482fd87d5"
],
"__v": 0
}
]
Getting user's archived tickets
Request body
{
"username": USERNAME, // string
"secret": SECRET // string
}
Response 200 example (JSON)
[
{
"_id": "663c5fe2a3708a9482fd87dd",
"quantity": 1,
"price": 4,
"isArchived": true,
"event": [
"663bd29bd2d1a07681577ca9"
],
"user": [
"663c5e2fa3708a9482fd87d5"
],
"__v": 0
}
]