mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-28 07:20:49 -04:00

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
21 lines
639 B
TypeScript
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();
|
|
});
|
|
}),
|
|
});
|
|
});
|