mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 03:26:07 +00:00
724c88c201
A mechanical prettier --write over server/src, server/tests, server/scripts and shared/src with the workspaces' .prettierrc; nothing but layout and import order changes, and every file keeps the same set of imports. shared is formatted throughout and its format baseline is empty. The server baseline keeps the 35 files that Prettier would grow past their lint:size limit (they need a split first, which is not a formatting change), and the generated entity files stay as their generator writes them.
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
import { RuntimeEnvService } from '../app-config/runtime-env.service';
|
|
import { logError } from '../audit/audit-log.logger';
|
|
import { CronRegistrarService } from '../scheduling/cron-registrar.service';
|
|
import { AdminService } from './admin.service';
|
|
import { Injectable, type OnApplicationBootstrap } from '@nestjs/common';
|
|
|
|
/**
|
|
* Daily version check (moved from src/scheduler.ts — it was the only consumer
|
|
* of the old admin bridge, which died with the move). checkAndNotifyVersion
|
|
* shares the module-scoped 5-minute cache in admin.helpers.ts with
|
|
* GET /api/admin/version-check, so the cron and the route hit GitHub once
|
|
* between them. No boot log — parity with the old starter.
|
|
*/
|
|
@Injectable()
|
|
export class VersionCheckJob implements OnApplicationBootstrap {
|
|
constructor(
|
|
private readonly admin: AdminService,
|
|
private readonly registrar: CronRegistrarService,
|
|
private readonly env: RuntimeEnvService,
|
|
) {}
|
|
|
|
onApplicationBootstrap(): void {
|
|
if (!this.registrar.isEnabled()) return;
|
|
// A centrally administered install never registers it. The upgrade schedule
|
|
// is the operator's, so the daily call to github.com would only ever produce
|
|
// a notification telling the admin to do something they cannot do.
|
|
if (this.env.isManaged()) return;
|
|
this.registrar.register('version-check', '0 9 * * *', () => this.tick());
|
|
}
|
|
|
|
async tick(): Promise<void> {
|
|
try {
|
|
await this.admin.checkAndNotifyVersion();
|
|
} catch (err: unknown) {
|
|
logError(`Version check: ${err instanceof Error ? err.message : err}`);
|
|
}
|
|
}
|
|
}
|