A Bun application that syncs your advert data from the Guntrader API, stores it in a Postgresql database, and manages images by uploading them to to any S3 compatible storage. The application uses a cron job to update the database periodically and ensures that obsolete data is removed, including deleting related images from storage.
- Fetches gun data from the Guntrader API.
- Upserts gun records into a database using Prisma.
- Uploads gun images to DigitalOcean Spaces.
- Deletes old/obsolete guns and corresponding images from both the database and DigitalOcean.
- Runs periodically using
node-cron
.
Clone this repository.
Install dependencies:
bun install
To run:
bun run dev
Provide the following env variables in your own .env file:
GUNTRADER_API_KEY=your_guntrader_api_key
- S3_ACCESS_KEY=your_S3_access_key
- S3_SECRET_KEY=your_S3_secret_key
- S3_SPACE_NAME=your_space_name
- S3_REGION=your_space_region
- S3_ENDPOINT=your_s3_endpoint
DATABASE_URL=postgresql://username:password@localhost:5432/dbname