Adaline Simonian 979aa097c7
feat: macrolanguage landing page for no locale
Auto-redirects:
- if the page requested is a user profile, and the user has one profile
  out of the multiple individual languages, to the one profile that was
  found
- otherwise based on user's accept-language header
- if all else fails, shows language selection landing page
2025-01-15 16:18:01 -08:00

21 lines
639 B
TypeScript

import { eventHandler } from 'h3';
import { defineNitroPlugin } from 'nitropack/runtime';
import { closeAuditLogConnection } from '../audit.ts';
import { LazyDatabase } from '../index.ts';
export default defineNitroPlugin((nitroApp) => {
nitroApp.h3App.stack.unshift({
route: '',
handler: eventHandler(async (event) => {
if (!event.context.db) {
event.context.db = new LazyDatabase();
}
event.node.res.on('close', async () => {
await event.context.db.close();
await closeAuditLogConnection();
});
}),
});
});