mirror of
https://github.com/moeru-ai/airi.git
synced 2026-08-14 00:48:06 +00:00
fix(server): reconcile auth split with main
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { Database } from './libs/db'
|
||||
import type { Env } from './libs/env'
|
||||
import type { ApiOtelInstance } from './otel'
|
||||
import type { OtelInstance } from './otel'
|
||||
import type { StreamingTtsVoiceType } from './routes/audio-speech-ws/session'
|
||||
import type { ConfigKVService } from './services/adapters/config-kv'
|
||||
import type { AdminFluxGrantsService } from './services/domain/admin/flux-grants'
|
||||
@@ -110,7 +110,7 @@ interface AppDeps {
|
||||
envelopeCrypto: EnvelopeCrypto
|
||||
redis: Redis
|
||||
env: Env
|
||||
otel: ApiOtelInstance | null
|
||||
otel: OtelInstance | null
|
||||
userDeletionService: UserDeletionService
|
||||
llmRouter: LlmRouterService
|
||||
providerCatalogService: ProviderCatalogService
|
||||
@@ -119,7 +119,7 @@ interface AppDeps {
|
||||
export async function buildApp(deps: AppDeps) {
|
||||
const logger = useLogger('app').useGlobalConfig()
|
||||
const userMetricsRecorder = deps.otel
|
||||
? registerUserMetricsSnapshotGauges(deps.otel.user)
|
||||
? registerUserMetricsSnapshotGauges(deps.otel.auth)
|
||||
: createDiscardingUserMetricsSnapshotRecorder()
|
||||
|
||||
const app = new Hono<HonoEnv>()
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { pushSchema as PushSchema } from 'drizzle-kit/api'
|
||||
|
||||
import { createRequire } from 'node:module'
|
||||
|
||||
import { PGlite } from '@electric-sql/pglite'
|
||||
import { drizzle } from 'drizzle-orm/pglite'
|
||||
|
||||
import * as authSchema from '@proj-airi/auth-shared'
|
||||
|
||||
/** Creates an in-memory database with the standalone Auth service schema. */
|
||||
export async function createTestDatabase() {
|
||||
const client = new PGlite()
|
||||
const database = drizzle(client)
|
||||
|
||||
// NOTICE:
|
||||
// drizzle-kit's `api` entry is CommonJS while this Vitest project is ESM.
|
||||
// Loading it via createRequire preserves its public runtime boundary.
|
||||
// Source/context: server/apps/api/src/libs/mock-db.ts uses the same drizzle-kit API.
|
||||
// Removal condition: drizzle-kit exposes a working ESM API entry.
|
||||
const require = createRequire(import.meta.url)
|
||||
const { pushSchema } = require('drizzle-kit/api') as { pushSchema: typeof PushSchema }
|
||||
const { apply } = await pushSchema(authSchema, database)
|
||||
await apply()
|
||||
|
||||
return database
|
||||
}
|
||||
Reference in New Issue
Block a user