adds api gpx upload route

This commit is contained in:
Christian Beutel
2024-03-21 18:46:25 +01:00
parent 01dfea0a03
commit 2ab0334579
22 changed files with 625 additions and 35 deletions

View File

@@ -1,4 +1,6 @@
import { env } from '$env/dynamic/private'
import { env as envPub } from '$env/dynamic/public'
import { pb } from '$lib/pocketbase'
import { isRouteProtected } from '$lib/util/authorization_util'
import { redirect, type Handle } from '@sveltejs/kit'
@@ -11,11 +13,14 @@ export const handle: Handle = async ({ event, resolve }) => {
const url = new URL(event.request.url);
// validate the user existence and if the path is acceesible
if (!pb.authStore.model && isRouteProtected(url.pathname)) {
throw redirect(302, '/login?r=' + url.pathname);
} else if (pb.authStore.model && url.pathname === "/login") {
throw redirect(302, '/');
} else if (envPub.PUBLIC_DISABLE_SIGNUP === "true" && url.pathname === "/register") {
throw redirect(302, '/');
}
try {
@@ -34,7 +39,7 @@ export const handle: Handle = async ({ event, resolve }) => {
} else {
const r = await event.fetch(pb.buildUrl("/public/search/token"));
const response = await r.json();
meiliApiKey = response.token;
meiliApiKey = response.token;
}
const ms = new MeiliSearch({ host: env.MEILI_URL, apiKey: meiliApiKey });