Files
dahyeon 8d741ef9a7 test(auction): add two-node Docker failure integration suite
Exercise Nginx routing, Mongo transaction ordering, history backfills, Undo, Pub/Sub TCP loss, safety polling, resync, and reconnection. Keep fixtures and results isolated from production and git.
2026-11-12 01:49:35 +09:00
..
2026-04-05 00:21:00 +09:00
2026-04-05 00:21:00 +09:00
2026-04-05 00:21:00 +09:00
2026-04-05 00:21:00 +09:00

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

Description

Nest framework TypeScript starter repository.

Riot Background Refresh

Stale Riot accounts refresh automatically between KST 03:00 and 10:00. The scheduler picks active users whose lastRefreshRequestedAt is older than 6 hours, oldest first, and uses a background-only Riot token bucket capped at roughly 40% of the app rate limit.

Project setup

$ pnpm install

Compile and run the project

# development
$ pnpm run start

# watch mode
$ pnpm run start:dev

# production mode
$ pnpm run start:prod

Run tests

# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov

# auction cancellation/undo transactions against a real local MongoDB replica set
$ pnpm run test:mongodb

test:mongodb requires mongod on PATH, or MONGODB_TEST_SERVER set to its executable path. The runner starts an isolated replica set on a random loopback port, uses a temporary database directory, and removes it after the tests. It does not use the application's database connection settings.

Temporary auction role selection

Until captain accounts are issued, bids use the team selected in the auction UI. By default, both WebSocket and HTTP bids accept guests and signed-in users without checking whether the user is that team's captain. Team existence, bid amounts, remaining points, roster limits, deadlines and round consistency are still checked. Bid history continues to identify the selected team's captain, so it is not proof of the account that submitted a bid in this temporary mode.

After issuing accounts, set AUCTION_REQUIRE_CAPTAIN_AUTH=true in the API environment (or project.env) and restart the API to require a signed-in captain for the selected team on all bid paths. Unset or false keeps temporary mode.

Auction durability

Accepted Redis bids now enter auction:bidArchivePayloads and auction:bidArchiveQueue atomically with the bid. The durability scheduler saves them to auctionBidRecords using deterministic IDs before removing queue entries. Recent state snapshots remain capped at 1000 bids; the archive is not capped and retains accepted bids across undo/cancellation for audit. These records begin with this deployment; bids already discarded by an older version cannot be recovered. GET /communities/:communityId/matches/:matchId/auction/bids/history pages through the current lifecycle's persisted archive using afterRevision and limit (1–200). Persistence is asynchronous, so an empty last page may gain entries afterward.

Invalid archive entries are moved atomically to auction:bidArchiveDeadLetterQueue and auction:bidArchiveDeadLetterPayloads. The payload stores the original text (or null for a missing payload), error, ID, and quarantine time. Monitor these keys and review quarantined data before repairing/requeuing it; it is not retried automatically or expired. Other bids continue to persist. Mongo write failures leave valid entries in the pending queue for idempotent retries.

Older in-flight rounds can produce bidRoundId: ''; the archive treats this as an absent optional round ID. Empty player IDs and other invalid field types remain validation errors.

Cancellation commits its completion marker and pending cleanup fields in Match. The scheduler retries cleanup after restarts, with a delay capped at 60 seconds. Reset notifications include the lifecycle to protect a newly started auction. Dead-letter status notifications use auction:deadLetterStatusQueue; failures to persist or mirror the terminal status are retried without rerunning the side effect. Older side-effect dead letters are also reconciled automatically.

Before deploying the cleanup worker, create its partial Match index using the additive, repeatable migration below. Schema declarations alone do not create indexes when MONGODB_AUTO_INDEX is disabled (the default). Choose the target environment explicitly; dry-run does not create indexes or modify documents.

pnpm --filter api auction:indexes -- --env staging --dry-run
pnpm --filter api auction:indexes -- --env staging --apply
# Use --env prod for production.

The index is { auctionCancellationCleanupRetryAt: 1 }, restricted to { auctionCancellationCleanupPending: true }. The worker only reads due pending entries; it no longer scans legacy cancellation markers without a pending flag.

Riot archive recovery

Newly saved or repaired Riot match data refreshes affected internal match statistics at the same Competition revision. Existing archives and duplicate imports do not trigger recovery. Recovery failures are logged and do not block result collection or match refresh. Only communities with recovered statistics have their caches invalidated, once per recovery batch; one failed rebuild does not prevent other successful rebuilds from being reflected. Detail requests also check for newly archived data when a cached game is missing raw data. An absent archive does not trigger a rebuild or a Riot match fetch. If a detail rebuild makes no progress, the process waits 60 seconds before retrying that source revision and does not invalidate the community cache.

Recovery cache invalidations first try Redis with a one-second command timeout. On failure they return immediately and schedule up to three in-process retries, waiting 1, 5, then 30 seconds between attempts. A community has one retry budget; additional immediate failures do not reset it, and a successful current request cancels the pending retry. Timers are unreferenced and cleared on shutdown. Retries are not persisted or resumed after a restart. Detail requests detect newly archived raw data even behind a stale cache, and other response caches expire after five minutes. A detail response whose immediate invalidation fails is returned without being cached. No Mongo invalidation collection or periodic queue scan is used.

Before deploying this recovery path, add its Riot ID lookup index. The migration defaults to dry-run and leaves other indexes and game records unchanged.

pnpm --filter api stats:indexes -- --env staging --dry-run
pnpm --filter api stats:indexes -- --env staging --apply
# Use --env prod for production.

Deployment

When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.

If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:

$ pnpm install -g @nestjs/mau
$ mau deploy

With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.

Resources

Check out a few resources that may come in handy when working with NestJS:

  • Visit the NestJS Documentation to learn more about the framework.
  • For questions and support, please visit our Discord channel.
  • To dive deeper and get more hands-on experience, check out our official video courses.
  • Deploy your application to AWS with the help of NestJS Mau in just a few clicks.
  • Visualize your application graph and interact with the NestJS application in real-time using NestJS Devtools.
  • Need help with your project (part-time to full-time)? Check out our official enterprise support.
  • To stay in the loop and get updates, follow us on X and LinkedIn.
  • Looking for a job, or have a job to offer? Check out our official Jobs board.

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.