205 lines
11 KiB
Markdown
205 lines
11 KiB
Markdown
<p align="center">
|
||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||
</p>
|
||
|
||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||
|
||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||
<p align="center">
|
||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
|
||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
|
||
</p>
|
||
<!--[](https://opencollective.com/nest#backer)
|
||
[](https://opencollective.com/nest#sponsor)-->
|
||
|
||
## Description
|
||
|
||
[Nest](https://github.com/nestjs/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
|
||
|
||
```bash
|
||
$ pnpm install
|
||
```
|
||
|
||
## Compile and run the project
|
||
|
||
```bash
|
||
# development
|
||
$ pnpm run start
|
||
|
||
# watch mode
|
||
$ pnpm run start:dev
|
||
|
||
# production mode
|
||
$ pnpm run start:prod
|
||
```
|
||
|
||
## Run tests
|
||
|
||
```bash
|
||
# 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.
|
||
|
||
```bash
|
||
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.
|
||
|
||
```bash
|
||
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](https://docs.nestjs.com/deployment) for more information.
|
||
|
||
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
|
||
|
||
```bash
|
||
$ 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](https://docs.nestjs.com) to learn more about the framework.
|
||
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
|
||
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
|
||
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
|
||
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
|
||
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
|
||
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
|
||
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
|
||
|
||
## 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](https://docs.nestjs.com/support).
|
||
|
||
## Stay in touch
|
||
|
||
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
|
||
- Website - [https://nestjs.com](https://nestjs.com/)
|
||
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||
|
||
## License
|
||
|
||
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
|