Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
node_modules
npm-debug.log
dist
coverage
.git
.github
test
README.md
.env
.env.local
docker-compose.override.yml
.dockerignore
*.log
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
107 changes: 14 additions & 93 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,100 +1,21 @@
# Server
PORT=4000

# Redis
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_URL=redis://redis:6379

# Database
DATABASE_URL=postgres://smartdrop:smartdrop@postgres:5432/smartdrop
# Runtime environment
# NODE_ENV: string enum (development, test, production). Default: development.
NODE_ENV=development

# PORT: number. Default: 3000.
PORT=3000
APP_URL=http://localhost:3001

# Database
DATABASE_URL=postgres://postgres:postgres@localhost:5432/smartdrop

# Stellar Horizon
# REDIS_URL: URL. Required in production. Development/test default: redis://localhost:6379.
REDIS_URL=redis://localhost:6379

# DATABASE_URL: URL. Required in production. Development default: postgres://localhost/smartdrop. Test default: postgres://localhost/smartdrop_test.
DATABASE_URL=postgres://localhost/smartdrop

# STELLAR_HORIZON_URL: URL. Default: https://horizon.stellar.org.
STELLAR_HORIZON_URL=https://horizon.stellar.org

# Soroban event indexer
SOROBAN_RPC_URL=https://soroban-rpc.mainnet.stellar.gateway.fm
SMARTDROP_CONTRACT_ID=
INDEXER_ENABLED=true
INDEXER_POLL_INTERVAL_MS=5000
INDEXER_POLL_LIMIT=100
INDEXER_START_LEDGER=0

# Stellar USDC Issuer
# USDC_ISSUER: Stellar public key. Default: Stellar USDC issuer.
USDC_ISSUER=GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335AX2OBFLDTQLNUEHRGPTM6RIA

# COINGECKO_API_KEY: string. Optional. Default: empty.
COINGECKO_API_KEY=

# COINMARKETCAP_API_KEY: string. Optional. Default: empty.
COINMARKETCAP_API_KEY=

# PRICE_CACHE_TTL_SECONDS: number. Default: 60.
PRICE_CACHE_TTL_SECONDS=60

# PRICE_REFRESH_INTERVAL_SECONDS: number. Default: 30.
PRICE_REFRESH_INTERVAL_SECONDS=30

# PRICE_STALE_THRESHOLD_MINUTES: number. Default: 5.
PRICE_STALE_THRESHOLD_MINUTES=5

# PRICE_ANOMALY_THRESHOLD_PCT: number. Default: 20.
PRICE_ANOMALY_THRESHOLD_PCT=20

# AIRDROP_EXPIRY_CHECK_INTERVAL_SECONDS: number. Default: 60.
AIRDROP_EXPIRY_CHECK_INTERVAL_SECONDS=60

# AIRDROP_LEDGER_CACHE_TTL_MS: number. Default: 5000.
AIRDROP_LEDGER_CACHE_TTL_MS=5000

# AIRDROP_EXPIRY_SCAN_BATCH_SIZE: number. Default: 100.
AIRDROP_EXPIRY_SCAN_BATCH_SIZE=100

# Airdrop request limits
# Maximum recipient CSV upload size in bytes. Default: 5 MiB.
AIRDROP_CSV_MAX_BYTES=5242880
# Maximum JSON request body size in bytes. Default: 2 MiB, sufficient for 10,000 recipients.
AIRDROP_JSON_MAX_BYTES=2097152
# Per-IP limits for airdrop creation and recipient additions.
AIRDROP_RATELIMIT_WINDOW=60
AIRDROP_RATELIMIT_MAX=10

# WATCHED_ASSETS: comma-separated CODE or CODE:ISSUER values warmed before startup.
WATCHED_ASSETS=XLM,USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN
# postgresql://user:password@host:5432/db
DATABASE_URL=

# API key auth
ADMIN_API_KEY=
# Must be at least 32 characters.
JWT_SECRET=

# LOG_LEVEL: string enum (debug, info, warn, error). Default: info.
LOG_LEVEL=info
# Soroban RPC endpoint (e.g. https://soroban-testnet.stellar.org)
SOROBAN_RPC_URL=
STELLAR_NETWORK=testnet

# Rate limiting (Redis-backed, per IP)
# RATE_LIMIT_WINDOW_MS: global API window in milliseconds. Default: 60000 (1 minute).
RATE_LIMIT_WINDOW_MS=60000
# RATE_LIMIT_MAX: max requests per IP per global window. Default: 100.
RATE_LIMIT_MAX=100
# PRICE_RATELIMIT_WINDOW: price endpoint window in seconds. Default: 60.
PRICE_RATELIMIT_WINDOW=60
# PRICE_RATELIMIT_MAX: max price requests per IP per window. Default: 30.
PRICE_RATELIMIT_MAX=30
# Deployed StellarTickets/blockchain `ticketing` contract address (C...)
TICKETING_CONTRACT_ID=

# CORS
CORS_ALLOWED_ORIGINS=http://localhost:4000,http://localhost:3001
# Platform hot wallet used ONLY as a disposable source account for read-only
# contract simulations (verify_ticket, get_event). Never used to sign a
# write, and never a user's key.
PLATFORM_SIGNER_SECRET=
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto eol=lf
*.ts text
*.json text
*.md text
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @presidojay1
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [presidojay1]
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Bug report
about: Report a problem with the API
labels: bug
---

**Endpoint affected**

**Request/response**

**Expected behavior**

**Actual behavior**
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Question or discussion
url: https://github.com/orgs/StellarTickets/discussions
about: Ask questions or discuss ideas before filing an issue
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: Feature request
about: Suggest a new API capability
labels: enhancement
---

**What problem does this solve?**

**Proposed endpoint(s) or schema changes**
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/security_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: Security report
about: Do not use this template — see SECURITY.md instead
labels: security
---

Please do not report security vulnerabilities through public GitHub
issues. See [SECURITY.md](../../SECURITY.md) for the private
disclosure process.
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Summary

## Testing
- [ ] `npx tsc --noEmit` passes
- [ ] `npx eslint "src/**/*.ts"` passes
- [ ] `npm test` passes
- [ ] `npm run build` succeeds
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
6 changes: 6 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
daysUntilStale: 60
daysUntilClose: 14
staleLabel: stale
markComment: >
This issue has been automatically marked as stale due to inactivity
and will be closed if no further activity occurs.
86 changes: 30 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,35 @@
name: CI

on:
pull_request:
branches:
- main
push:
branches:
- main

permissions:
contents: read
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
NODE_ENV: test
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
COINGECKO_API_KEY: ${{ secrets.COINGECKO_API_KEY }}
COINMARKETCAP_API_KEY: ${{ secrets.COINMARKETCAP_API_KEY }}
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Lint OpenAPI spec
run: npx @redocly/cli lint openapi.yaml

- name: Run tests
run: npm test

docker-build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Build Docker image
run: docker build -t smartdrop-backend:ci .
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- run: npm ci

- name: Generate Prisma client
run: npx prisma generate

- name: Typecheck
run: npx tsc --noEmit

- name: Lint
run: npx eslint "src/**/*.ts"

- name: Unit tests
run: npm test

- name: Build
run: npm run build
36 changes: 0 additions & 36 deletions .github/workflows/deploy.yml

This file was deleted.

25 changes: 20 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
node_modules/
# compiled output
/dist
/node_modules

# logs
logs
*.log
npm-debug.log*

# env
.env
.env.local
.env.*.local
dist/
coverage/
*.log

# coverage
/coverage
/.nyc_output

# IDE
.idea
.vscode

# OS
.DS_Store
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
6 changes: 6 additions & 0 deletions ACKNOWLEDGEMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Acknowledgements

Built with [NestJS](https://nestjs.com/), [Prisma](https://www.prisma.io/),
and the [Stellar SDK](https://github.com/stellar/js-stellar-sdk), against
the [`ticketing`](https://github.com/StellarTickets/blockchain) Soroban
contract.
Loading
Loading