Customizable notification service for Too Good To Go (TGTG) application.
If you have ever used the TGTG application, you have probably had, like me, a great deal of frustration. The frustration of not being able to set up notifications on this application. You can only open the application compulsively at the times when baskets are usually available, otherwise you are condemned to systematically go last, and nothing is available anymore.
When a basket is available in your area, you receive an instant SMS notification. No delay.
Fully configurable cooldowns that ensure you don't get spammed with notifications :
- A first high-level cooldown that blocks all notifications for X hours once notified
- A much more precise cooldown configured by store, which ensures some variety in notifications. You then can't get notified for a store that already notified you for X hours.
You can enter the specific times of the day you wish to be notified. You will never be notified outside of these ranges. This ensures that you are not notified at critical times such as at night or during your working hours for example.
- Download and install Docker Desktop.
- Setup your AWS CLI.
Create a docker-compose.yml
file, put this snippet in it :
version: "3.8"
services:
dynamodb-local:
command: "-jar DynamoDBLocal.jar -sharedDb -optimizeDbBeforeStartup -dbPath ./data"
image: "amazon/dynamodb-local:latest"
container_name: dynamodb-local
ports:
- "8000:8000"
volumes:
- "./docker/dynamodb:/home/dynamodblocal/data"
working_dir: /home/dynamodblocal
Go to your Terminal, go to the folder where you created the docker-compose file, and run this :
docker-compose up -d
You know have a local DynamoDB service up & running.
You can work with a pretty useful DynamoDB GUI for your local interactions with dynamo. Simply install the lib globally :
npm i -g dynamodb-admin
Then run on your Terminal :
DYNAMO_ENDPOINT=http://localhost:8000 dynamodb-admin
You can then open your browser to http://localhost:8001
(whatever the execution script tells you) to access GUI.
If you use the GUI, you can easily create your data.
Create Table :
Create a table named like what is in serverless env variable DYNAMODB_CONSUMERS_TABLE
Hash attribute name contact
of type String
Leave everything like it is, click Submit.
Go in this table and click Create Item, use this sample data :
{
"lastNotificationDate": 1606359175685,
"lastStoreNotif": [],
"location": {
"lat": 50.62679972997623,
"long": 3.0567717525498934
},
"notifPreference": [
{
"end": "14:00",
"start": "12:00"
},
{
"end": "19:00",
"start": "16:30"
},
{
"end": "22:00",
"start": "21:00"
}
],
"contact": "[email protected]",
"radius": 5
}
You can replace location, notifPreference, contact and radius with values you want.
You can now run npm run offline
, and, ta-da !
You can now trigger the script via HTTP request and it'll fully work.
The SNS notification is mocked, nothing will be sent, for tests purpose. But every other feature works as in production.
When everything is setup, you'll just need to run the docker-compose up -d
command to run DynamoDB local if the container is down, and run npm run offline
.