feat(api): await startup
This commit is contained in:
parent
ed424d78fd
commit
3bb5a4999d
@ -42,7 +42,7 @@ app.get(
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
startup()
|
await startup()
|
||||||
export default {
|
export default {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
fetch: app.fetch,
|
fetch: app.fetch,
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user