mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-08 15:00:37 -04:00
28 lines
697 B
TypeScript
28 lines
697 B
TypeScript
import * as Sentry from '@sentry/node';
|
|
import SQL from 'sql-template-strings';
|
|
|
|
export default defineEventHandler(async () => {
|
|
const { version } = useRuntimeConfig();
|
|
|
|
const db = useDatabase();
|
|
|
|
try {
|
|
const { migrationsCount } = await db.get(
|
|
SQL`SELECT COUNT(*) as migrationsCount FROM migrations`,
|
|
) as { migrationsCount: number };
|
|
|
|
return {
|
|
databaseOnline: migrationsCount > 0,
|
|
version,
|
|
};
|
|
} catch (error) {
|
|
console.error(error);
|
|
Sentry.captureException(error);
|
|
|
|
throw createError({
|
|
status: 500,
|
|
statusMessage: 'Unexpected server error',
|
|
});
|
|
}
|
|
});
|