11/* eslint-disable @typescript-eslint/no-explicit-any */
22import { type FastifyInstance , type FastifyBaseLogger } from 'fastify' ;
3- import { getDb , getSchema } from '../../db' ;
3+ import { getDb } from '../../db' ;
4+ import { dynamicOauthClients } from '../../db/schema.sqlite' ;
45import { eq } from 'drizzle-orm' ;
56
67// Database-backed client registration functions
78export async function isClientRegistered ( clientId : string , logger : FastifyBaseLogger ) : Promise < boolean > {
89 try {
910 const db = getDb ( ) ;
10- const schema = getSchema ( ) ;
1111
12- const result = await ( db as any )
12+ const result = await db
1313 . select ( )
14- . from ( schema . dynamicOauthClients )
15- . where ( eq ( schema . dynamicOauthClients . client_id , clientId ) )
14+ . from ( dynamicOauthClients )
15+ . where ( eq ( dynamicOauthClients . client_id , clientId ) )
1616 . limit ( 1 ) ;
1717
1818 return result . length > 0 ;
@@ -29,12 +29,11 @@ export async function isClientRegistered(clientId: string, logger: FastifyBaseLo
2929export async function getRegisteredClient ( clientId : string , logger : FastifyBaseLogger ) : Promise < any > {
3030 try {
3131 const db = getDb ( ) ;
32- const schema = getSchema ( ) ;
3332
34- const result = await ( db as any )
33+ const result = await db
3534 . select ( )
36- . from ( schema . dynamicOauthClients )
37- . where ( eq ( schema . dynamicOauthClients . client_id , clientId ) )
35+ . from ( dynamicOauthClients )
36+ . where ( eq ( dynamicOauthClients . client_id , clientId ) )
3837 . limit ( 1 ) ;
3938
4039 return result [ 0 ] || null ;
@@ -51,11 +50,10 @@ export async function getRegisteredClient(clientId: string, logger: FastifyBaseL
5150export async function getRegisteredClientsDebugInfo ( logger : FastifyBaseLogger ) : Promise < any > {
5251 try {
5352 const db = getDb ( ) ;
54- const schema = getSchema ( ) ;
5553
56- const allClients = await ( db as any )
54+ const allClients = await db
5755 . select ( )
58- . from ( schema . dynamicOauthClients ) ;
56+ . from ( dynamicOauthClients ) ;
5957
6058 return {
6159 mapSize : allClients . length ,
@@ -224,7 +222,6 @@ export default async function registerRoute(server: FastifyInstance) {
224222 try {
225223 // Store client registration in database
226224 const db = getDb ( ) ;
227- const schema = getSchema ( ) ;
228225
229226 const dbRegistration = {
230227 client_id,
@@ -238,7 +235,7 @@ export default async function registerRoute(server: FastifyInstance) {
238235 expires_at : null , // No expiration for now
239236 } ;
240237
241- await ( db as any ) . insert ( schema . dynamicOauthClients ) . values ( dbRegistration ) ;
238+ await db . insert ( dynamicOauthClients ) . values ( dbRegistration ) ;
242239
243240 request . log . info ( {
244241 operation : 'dynamic_client_registration' ,
0 commit comments