feat(api): await startup
All checks were successful
Build and Push Docker Image / tests (push) Successful in 26s
Build and Push Docker Image / build (push) Successful in 1m28s

This commit is contained in:
Lars Hampe 2024-10-01 20:58:51 +02:00
parent ed424d78fd
commit 3bb5a4999d
3 changed files with 12 additions and 5 deletions

View File

@ -42,7 +42,7 @@ app.get(
}), }),
) )
startup() await startup()
export default { export default {
port: 3000, port: 3000,
fetch: app.fetch, fetch: app.fetch,

View File

@ -9,7 +9,7 @@ declare module 'bun' {
} }
} }
export const startup = () => { export const startup = async () => {
if (import.meta.env.NODE_ENV === 'test') { if (import.meta.env.NODE_ENV === 'test') {
if (!import.meta.env.POSTGRES_URL) { if (!import.meta.env.POSTGRES_URL) {
console.error('Env Var POSTGRES_URL is missing!') console.error('Env Var POSTGRES_URL is missing!')
@ -30,5 +30,5 @@ export const startup = () => {
} }
}) })
migrateDatabase() await migrateDatabase()
} }

View File

@ -3,6 +3,13 @@ import { migrate } from 'drizzle-orm/postgres-js/migrator'
import { client, db } from './' import { client, db } from './'
export const migrateDatabase = async () => { export const migrateDatabase = async () => {
await migrate(db, { migrationsFolder: path.join(__dirname, 'migrations') }) try {
await client.end() console.log(__dirname)
await migrate(db, { migrationsFolder: path.join(__dirname, 'migrations') })
await client.end()
console.log('Migrations: Ok')
} catch (error) {
console.error('Migrations: Failed')
console.error(error)
}
} }