(Bookings server) | (Bookings app)
The bookings back-end is an Amazon Web Services lambda function written in Node.js.
In deployment, the API is located at: https://api.makerspacedelft.nl/prod
The major API calls are listed below. This is just a brief high-level overview of what is contained within the AWS lambda function:
| HTTP Method | URL | Description |
|---|---|---|
| GET | https://api.makerspacedelft.nl/prod?action=client | Return user info |
| POST | https://api.makerspacedelft.nl/prod?action=client | Sign in or register |
| POST | https://api.makerspacedelft.nl/prod?action=bookings | Create a booking |
| GET | https://api.makerspacedelft.nl/prod?action=bookings | View bookings |
| DELETE | https://api.makerspacedelft.nl/prod?action=bookings | Cancel a booking |
| GET | https://api.makerspacedelft.nl/prod?action=calendar | Outputs data in ICS format for all the bookings. |
For more, see LambdaFE/app.js and LambdaFE/routes.js.
These methods do not check user authentication.
New code pushed to the main branch on GitHub is automatically deployed to AWS. This works via a CI/CD process as follows:
- When new code is pushed to the main branch, the Serverless Application Model Deployment workflow runs. This is configured in .github/workflows/aws.yml and visible under the "Actions" tab.
- The workflow reads the AWS template template.yaml and from this generates gen/cloudformationtemplate.yaml.
- The workflow then deploys the services (DynamoDB and Lambda) on AWS according to this template file.
This means updating the code is as simple as pushing to git. The status of all deployments can be seen in the Actions tab in GitHub.
The secret access key is stored in the Settings tab of the repository and is referenced by aws.yml.
This is the tricky part of the back-end. Calendar events are pulled by rather than pushed to the calendar. This is done by a Google Apps Script which is configured to run every 5 minutes: MSD GAS-ICS-Sync
It calls the calendar function (from the API URL above) which returns all bookings in the database. It then detects new or deleted events and merges the changes into the shared Google Calendar.
The documentation for this script is at the top of the source code file. To restart the script:
- Open MSD GAS-ICS-Sync
- Make sure the toolbar says "install" to the right of "Debug"
- Click "Run"
Note that the calendar name is specified as a string: "Makerspace Delft Bookings". That means that if this name changes, or there are multiple calendars with this name accessible by the script owner, there may be an undesirable outcome.
All of the booking and user data is stored on AWS (in DynamoDB) and it may be wise to back this up regularly.
First, sign into the AWS console:
- https://console.aws.amazon.com/
- makerspacedelft
- makerspace
- [password]
View the DynamoDB database: https://console.aws.amazon.com/dynamodbv2/#tables