Functions as a Service Subscription Manager, obviously
A bare-bones non-scalable implementation of MongoDB ChangeStreams integration with Budibase Automation webhook workflows, which essentially gives a trigger management system. Although the examples use Budibase, it will work with any webhook that accepts an arbitrary HTTP POST.
- FastAPI - static webserver and APIs
- PicoCSS - Styling
- AlpineJS - interactivity
- Material Icons - Icons
- MongoDB - Database
- Deploy a backing MongoDB cluster
- Make sure a user exists with permissions on the
faas.subscriptionsandfaas.__keyvaultnamespaces - Put the connection string for that cluster in the .env file in the variable called
SPECUIMDBCONNSTR(as seen in thesample.envwhich can be copied and renamed to just.env) - Generate an encryption key with the command below and put in
MASTERENCKEYASBASE64value in the.envfile created in the last step. Only include the value from python within the single quotes (omit the starting and trailing single quote and the starting b)
>>> import os
>>> import base64
>>> base64.b64encode(os.urandom(96))
- DO NOT LOSE THE ABOVE as without it you will not be able to regain your data as it is encrypted
- Both variables should be in double quotes within the
.envfile
- Create a venv:
$ cd backend
$ python -m venv venv
- Edit
venv/bin/activateto put a new line at the end with contentsexport SPECUIMDBCONNSTR=$1 MASTERENCKEYASBASE64=$2 - Run
./activate.shscript
- Run
./build.sh
First, create a "New Stream":
- Name - any name you want
- Connection String - the connection string of the cluster to monitor the ChangeStream of. This is encrypted with pymongo and MongoDB's Queryable Encryption
- Database Name - the database namespace to use in the cluster
- Collection Name - the collection inside the database to watch
- Pipeline - The ChangeStream change event filter pipeline
- Webhook - the URL to which to HTTP POST the full change event
- Additional metadata context - any key/value you want to send in the payload. Will be in the
secretsMetadatafield. The value is stored encrypted in the database - Enabled - checkbox to enable/disable the watch
Upon saving or any modification, the system will watch that collection using the pipeline provided and forward any change_event to the URL provided as a POST
It may be useful to test the webhook. Using the "Test Webhook" button will send a sample test to the Webhook as a POST
This may be more useful when using Budibase as a Budibase Webhook will provide a Schema URL which you can put in the webhook field, press "Test Webhook" and then Budibase will know the schema of the POST message. Then you chan change the Webhook value to that of the Trigger URL and Save to begin watching it.








