Framework: ExpressJS
Language: TypeScript
Install necessary packages
npm i
Create a database in MySQL and put your configurations inside src/app-data-source.ts
Run seeding script
npm run seed
You can use Postman by importing the Insomnia_2022-11-20.json
file.
- events (id: PrimaryKey(Number), title: String, start_at: Datetime, end_at: Datetime)
- workshops (id: PrimaryKey(Number), event_id: ForeignKey(event_id), start_at: Datetime, end_at: Datetime, title: String, description: String)
- reservations (id: PrimaryKey(Number), name: String, email: String, workshop_id: ForeignKey(workshop_id)
- GET /events Get all events that are active(not started)
{
events:[
{
id: 1,
title: "Demo Event",
start_at: "2022-11-5T06:59:01.107Z",
end_at: "2022-11-10T06:59:01.107Z",
}
],
pagination:{
total: 50,
per_page: 10,
total_pages: 5,
current_page: 1
}
}
- GET /events/{id} Get single event information. e.g. /events/3
{
id: 3,
title: "Demo Event",
start_at: "2022-11-5T06:59:01.107Z",
end_at: "2022-11-10T06:59:01.107Z",
total_workshops: 30
}
- GET /events/{eventId}/workshops Get all the active workshops of a single event
{
id: 1,
title: "Demo Event",
start_at: "2022-11-5T06:59:01.107Z",
end_at: "2022-11-10T06:59:01.107Z",
workshops:[
{
id: 1,
title: "Demo Workshop",
description: "Demo Workshop description",
start_at: "2022-11-5T06:59:01.107Z",
end_at: "2022-11-5T06:59:01.107Z"
}
]
}
- GET /events/{eventId}/workshops/{workshopId} Get single workshop information
{
id: 1,
title: "Demo Workshop",
description: "This is demo workshop",
start_at: "2022-11-5T06:59:01.107Z",
end_at: "2022-11-5T06:59:01.107Z",
total_reservations: 100
}
- POST /events/{eventId}/workshops/{workshopId}/reservations
Request:
{
name: "User Name",
email: "username@gmail.com"
}
Response:
{
reservation: {
id: 1,
name: "User Name",
email: "username@gmail.com"
},
event:{
id: 1,
title: "Demo Event",
start_at: "2022-11-5T06:59:01.107Z",
end_at: "2022-11-10T06:59:01.107Z",
},
workshop:{
id: 1,
title: "Demo Workshop",
description: "Demo Workshop description",
start_at: "2022-11-5T06:59:01.107Z",
end_at: "2022-11-5T06:59:01.107Z"
}
}