A basic application that allows you to book events from different timezones
- Get free slots for a given date and timezone in user timezone
- Book an event
- See all the events booked in between startDate and end Date
- NodeJS & expressJS
- MomentJS & Moment-timezone (for handling timezones)
- EJS for template engine
- Firestore for database
npm init
npm i express moment moment-timezone firebase ejs
Dev dependencies
npm i --save-dev nodemon
Default timezone : America/Los_Angeles
Default slot duration: 30 min
Default starting time for bookings: 08:00 AM
Default ending time for bookings: 05:00 PM
-
getAvailableSlots(date, timezone) --> POST localhost:5000/slots/
This function takes date and timezone and returns all the available free slots to book an appointment.
-
addEvent(name, date, duration) --> POST localhost:5000/events/
This functions books an appointment with given duration. The 'date' should be in ISOformat string. If the duration clashes with other slots it will return error status(422)
-
getEvents(startDate, endDate). --> POST localhost:5000/events/allevents
This function returns all the events between startDate and endDate. The arguments should be in YYYY-MM-DD format
The firestore maintains two collections 'events' and 'slots'
1)Events (holds all the events information)
Events{
name: username,
date: date, ---> YYYY-MM-DD format
time: time,
duration: duration
}
2)Slots (holds the freeslots information)
Slots{
slotbox: [0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ]
}
slotbox array represents slots information for a day '0' represents free slot '1' represents booked slot
Ex: slotbox[0] ==> 08:00 AM
slotbox[1] ==> 08:30 AM
slotbox[17] ===> 04:30 PM
This array will make checking for freeslots easier
https://appointment-booker-app.herokuapp.com/
These are the results when I don't render in the backend and send json data with res.send(jsonData)