updated types a bit
This commit is contained in:
parent
d77bbb317d
commit
e18adab888
|
|
@ -6,6 +6,7 @@
|
|||
"@sveltejs/adapter-node": "^5.2.12",
|
||||
"@sveltejs/kit": "^2.20.4",
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
||||
"@types/bun": "^1.2.10",
|
||||
"@types/sqlite3": "^3.1.11",
|
||||
"svelte": "^5.25.6",
|
||||
"svelte-adapter-bun": "^0.5.2",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
// See https://svelte.dev/docs/kit/types#app.d.ts
|
||||
|
||||
import type { User } from "$lib/server/database";
|
||||
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
// interface Locals {}
|
||||
interface Locals {
|
||||
user: User
|
||||
}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,21 @@
|
|||
import type { Handle } from "@sveltejs/kit";
|
||||
import { error } from "@sveltejs/kit";
|
||||
|
||||
import { User, UserDB, init_db, close_db, create_user, get_user, get_user_db } from "$lib/server/database";
|
||||
import { init_db, close_db, get_user } from "$lib/server/database";
|
||||
|
||||
import { Database } from "bun:sqlite";
|
||||
async function init() {
|
||||
|
||||
function init() {
|
||||
if (process.env.APP_USER_DATA_PATH == null) {
|
||||
console.log("APP_USER_DATA_PATH is not defined. Exiting.");
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
if (process.env.APP_TMP_USER_DATA_PATH == null) {
|
||||
console.log("APP_TMP_USER_DATA_PATH is not defined. Exiting.");
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
init_db();
|
||||
await init_db();
|
||||
|
||||
console.log("started");
|
||||
|
||||
|
|
@ -16,24 +26,27 @@ function deinit() {
|
|||
console.log('exit');
|
||||
}
|
||||
|
||||
init();
|
||||
await init();
|
||||
|
||||
process.on('exit', (reason) => {
|
||||
process.on('exit', (_) => {
|
||||
deinit();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on('SIGINT', (reason) => {
|
||||
process.on('SIGINT', (_) => {
|
||||
console.log("SIGINT")
|
||||
process.exit(0);
|
||||
})
|
||||
|
||||
import { getAllFiles } from "$lib/server/docstore"
|
||||
|
||||
export async function handle({ event, resolve }) {
|
||||
export let handle: Handle = async function ({ event, resolve }) {
|
||||
|
||||
event.locals.user = get_user();
|
||||
console.log("handle");
|
||||
let user = get_user();
|
||||
|
||||
if (!user) {
|
||||
return error(404, "No user"); // redirect login
|
||||
}
|
||||
|
||||
event.locals.user = user;
|
||||
|
||||
return await resolve(event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
import { Database } from 'bun:sqlite';
|
||||
|
||||
export interface UserEntry {
|
||||
id: number;
|
||||
gender: string;
|
||||
|
|
|
|||
Loading…
Reference in New Issue