feat: add control plane authentication baseline
This commit is contained in:
1 parent
a4c93ff1a7
commit
0d10e2d124
21 files changed
+1403
-18
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { createRequire } from 'node:module'
|
||||
import { resolve } from 'node:path'
|
||||
|
||||
const databaseUrl = process.env.DATABASE_URL
|
||||
if (!databaseUrl) throw new Error('DATABASE_URL is required')
|
||||
|
||||
interface PgPool {
|
||||
query(text: string, values?: unknown[]): Promise<unknown>
|
||||
end(): Promise<void>
|
||||
}
|
||||
|
||||
interface PgPoolConstructor {
|
||||
new (options: { connectionString: string }): PgPool
|
||||
}
|
||||
|
||||
const runtimeRequire = createRequire(import.meta.url)
|
||||
const { Pool } = runtimeRequire('pg') as { Pool: PgPoolConstructor }
|
||||
const pool = new Pool({ connectionString: databaseUrl })
|
||||
const migration = await readFile(resolve(process.cwd(), 'migrations/001_auth.sql'), 'utf8')
|
||||
await pool.query(migration)
|
||||
await pool.end()
|
||||
console.log('Applied migration 001_auth.sql')
|
||||
Reference in new issue
Block a user