diff --git a/src/hooks.server.ts b/src/hooks.server.ts index d3d57e6..0ba0e24 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,7 +1,35 @@ import type { ServerInit } from '@sveltejs/kit'; +import { handles } from './handles/handle'; +import { SSLSnifferApp } from '$lib/db-utils/sqlite'; +import { UserApp } from '$lib/classes/users'; +import { UserDBBroker } from '$lib/db-utils/Users'; +import { SessionApp } from '$lib/classes/sessions'; +import { SessionDBBroker } from '$lib/db-utils/Sessions'; +import { AppData } from '$lib/classes/app-sessions'; +import { logger } from '$lib/utils/logger'; + +let initOnce = false export const init: ServerInit = async () => { + + if (initOnce) { + logger.debug("Already Started, avoiding reinitializing", "App Init") + return + } + + logger.debug("Starting app", "App Init") - // TODO: initialize db + SSLSnifferApp.init() + UserApp.init( + new UserDBBroker() + ) + SessionApp.init( + new SessionDBBroker() + ) -}; \ No newline at end of file + initOnce = true + logger.debug("Init run successfully", "App Init") + +}; + +export const handle = handles \ No newline at end of file