refactor(nest): inject DatabaseService in db-using controllers

This commit is contained in:
jubnl
2026-07-25 18:15:15 +02:00
parent fbe200424d
commit dd2c2d6668
16 changed files with 74 additions and 36 deletions
@@ -3,7 +3,7 @@ import type { Request, Response } from 'express';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { pluginsEnabled } from './kill-switch';
import { PluginOAuthService } from './plugin-oauth.service';
import { db } from '../../db/database';
import { DatabaseService } from '../database/database.service';
/**
* Host-brokered outbound OAuth endpoints (#plugins). All are gated by JwtAuthGuard —
@@ -15,10 +15,13 @@ import { db } from '../../db/database';
@Controller('api/plugin-oauth')
@UseGuards(JwtAuthGuard)
export class PluginOAuthController {
constructor(private readonly oauth: PluginOAuthService) {}
constructor(
private readonly oauth: PluginOAuthService,
private readonly dbs: DatabaseService,
) {}
private isActive(id: string): boolean {
return !!db.prepare("SELECT 1 FROM plugins WHERE id = ? AND status = 'active'").get(id);
return !!this.dbs.connection.prepare("SELECT 1 FROM plugins WHERE id = ? AND status = 'active'").get(id);
}
@Get(':id/status')