This project is a Deno script that runs on a schedule to delete temporary files from an S3 bucket and a PostgreSQL database. It uses the Deno standard library for loading environment variables, the Deno PostgreSQL library for interacting with the database, and the Deno S3 library for interacting with the S3 bucket.
- Clone the repository and navigate to the project directory.
- Install Deno: https://deno.land/#installation
- Run
deno run --allow-read --allow-env --allow-net --unstable-cron main.ts
to start the cleanup script.
Before running the script, make sure to set the following environment variables:
DIRECT_URL
: The URL of the PostgreSQL database.S3_UPLOAD_KEY
: The access key ID for the S3 bucket.S3_UPLOAD_SECRET
: The secret key for the S3 bucket.S3_UPLOAD_REGION
: The region of the S3 bucket.S3_UPLOAD_ENDPOINT
: The endpoint URL of the S3 bucket.S3_UPLOAD_BUCKET
: The name of the S3 bucket.
The cleanup script is scheduled to run every day using Deno's Deno.cron
function. You can modify the schedule by changing the cron expression in the script.