- TypeScript 99.9%
- Dockerfile 0.1%
|
All checks were successful
Deploy / deploy (push) Successful in 17s
|
||
|---|---|---|
| .forgejo/workflows | ||
| .vscode | ||
| .yaak | ||
| scripts | ||
| src | ||
| .env.example | ||
| .gitignore | ||
| bun.lock | ||
| compose.yaml | ||
| Dockerfile | ||
| drizzle.config.ts | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
API
Contribute?
Let's start with cloning the repository and install dependencies with Bun.
bun install
You have a few variables to setup, cp .env.example .env.dev and fill them.
bun dev
You can also store the production variables in .env.prod and use the following command to run with those variables.
bun dev:prod
Forwarding Stripe
You have to set the STRIPE_WEBHOOK_KEY variable in order to process payments locally.
You'll need the Stripe CLI in order to do this, the following commands are how you setup the forward.
stripe login
stripe listen --events payment_intent.succeeded --forward-to http://localhost:3000/throwdown/pay/receive
Production
CI/CD
We use a Forgejo workflow to automatically update and run the API in our production VPS with Docker.
You can find more information about it in the deploy.yml workflow.
PRIVATE_KEYvariable was generated using the following commands.ssh-keygen -t ed25519 -f ~/.ssh/deploy -N "" cat ~/.ssh/deploy.pub >> ~/.ssh/authorized_keys base64 -w 0 ~/.ssh/deploy # put this in `PRIVATE_KEY` variable!
Stripe
| Webhook Name | Events | URL |
|---|---|---|
Throwdown.PayReceive |
payment_intent.succeeded |
https://api.throwdown.live/throwdown/pay/receive |
Caddy
We're running the API behind a Cloudflare proxy to use the IP Geolocation feature.
api.throwdown.live {
reverse_proxy 127.0.0.1:6000 {
header_up X-Forwarded-For {remote_host}
}
}
Migrations
Anytime an update is done in the database schema, migrations should be generated with the following command.
bun migration:gen
When you think you're done and the migration looks good, you can apply them to either development or production database.
bun migration:push
bun migration:push:prod # uses .env.prod