mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 06:26:26 +00:00
refactor(nest): inject DatabaseService in db-using controllers
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user