mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-06-08 16:03:57 +02:00
39 lines
945 B
TypeScript
39 lines
945 B
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Headers,
|
|
HttpCode,
|
|
Post,
|
|
UnauthorizedException,
|
|
} from "@nestjs/common";
|
|
import { ConfigService } from "@nestjs/config";
|
|
import { SyncService } from "./sync.service.js";
|
|
|
|
@Controller("v1/internal")
|
|
export class InternalController {
|
|
private readonly internalKey: string | undefined;
|
|
|
|
constructor(
|
|
private readonly syncService: SyncService,
|
|
private readonly configService: ConfigService,
|
|
) {
|
|
this.internalKey = this.configService.get<string>("INTERNAL_KEY");
|
|
}
|
|
|
|
@Post("cleanup-excess-profiles")
|
|
@HttpCode(200)
|
|
async cleanupExcessProfiles(
|
|
@Headers("x-internal-key") key: string,
|
|
@Body() body: { userId: string; maxProfiles: number },
|
|
) {
|
|
if (!this.internalKey || key !== this.internalKey) {
|
|
throw new UnauthorizedException("Invalid internal key");
|
|
}
|
|
|
|
return this.syncService.cleanupExcessProfiles(
|
|
body.userId,
|
|
body.maxProfiles,
|
|
);
|
|
}
|
|
}
|