feat(api): add Riot webhook

This commit is contained in:
dahyeon committed 2026-04-09 01:24:00 +09:00
1 parent d6f52a8b15
commit 9f6974c577
2 files changed
+109

No files matched your search

@@ -0,0 +1,49 @@
import {
All,
Controller,
HttpCode,
HttpStatus,
Req,
} from '@nestjs/common';
import type { Request } from 'express';
import { AllowPublicAccess } from '../auth/allow-public-access.decorator';
type RiotWebhookRequest = Request & {
rawBody?: Buffer;
};
@Controller('riot')
export class RiotWebhookController {
@All('webhooks/tournament')
@AllowPublicAccess()
@HttpCode(HttpStatus.OK)
public captureTournamentWebhook(@Req() req: RiotWebhookRequest) {
const receivedAt = new Date().toISOString();
const rawBodyText = req.rawBody?.toString('utf8') ?? null;
const logPayload = {
receivedAt,
method: req.method,
url: req.originalUrl,
protocol: req.protocol,
hostname: req.hostname,
ip: req.ip,
ips: req.ips,
headers: req.headers,
query: req.query,
params: req.params,
body: req.body,
rawBodyLength: req.rawBody?.length ?? null,
rawBodyText,
};
console.log('\n[RIOT TOURNAMENT WEBHOOK] Incoming request');
console.dir(logPayload, { depth: null });
console.log('[RIOT TOURNAMENT WEBHOOK] End request log\n');
return {
ok: true,
message: 'Riot webhook received.',
receivedAt,
};
}
}