Fix: Resolve errors from untested previous commit

This commit is contained in:
Aron Malcher 2024-03-10 17:54:10 +01:00
parent 6550f703a5
commit 1b2673fc93
Signed by: aronmal
GPG key ID: 816B7707426FC612
10 changed files with 16 additions and 15 deletions

View file

@ -2,7 +2,7 @@
import "@fortawesome/fontawesome-svg-core/styles.css"; import "@fortawesome/fontawesome-svg-core/styles.css";
import { Meta, MetaProvider, Title } from "@solidjs/meta"; import { Meta, MetaProvider, Title } from "@solidjs/meta";
import { Router } from "@solidjs/router"; import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start"; import { FileRoutes } from "@solidjs/start/router";
import { Suspense } from "solid-js"; import { Suspense } from "solid-js";
import "./styles/global.scss"; import "./styles/global.scss";

View file

@ -1,3 +1,4 @@
// @refresh reload
import { StartServer, createHandler } from "@solidjs/start/server"; import { StartServer, createHandler } from "@solidjs/start/server";
export default createHandler(() => ( export default createHandler(() => (

View file

@ -12,8 +12,8 @@ let started: boolean = false;
export default createMiddleware({ export default createMiddleware({
onRequest: async (event) => { onRequest: async (event) => {
if (event.nativeEvent.node.req.method !== "GET") { if (event.nativeEvent.node.req.method !== "GET") {
const originHeader = getHeader(event, "Origin") ?? null; const originHeader = getHeader(event.nativeEvent, "Origin") ?? null;
const hostHeader = getHeader(event, "Host") ?? null; const hostHeader = getHeader(event.nativeEvent, "Host") ?? null;
if ( if (
!originHeader || !originHeader ||
!hostHeader || !hostHeader ||
@ -24,7 +24,8 @@ export default createMiddleware({
} }
} }
const sessionId = getCookie(event, lucia.sessionCookieName) ?? null; const sessionId =
getCookie(event.nativeEvent, lucia.sessionCookieName) ?? null;
if (!sessionId) { if (!sessionId) {
event.nativeEvent.context.session = null; event.nativeEvent.context.session = null;
event.nativeEvent.context.user = null; event.nativeEvent.context.user = null;
@ -34,18 +35,19 @@ export default createMiddleware({
const { session, user } = await lucia.validateSession(sessionId); const { session, user } = await lucia.validateSession(sessionId);
if (session && session.fresh) { if (session && session.fresh) {
appendHeader( appendHeader(
event, event.nativeEvent,
"Set-Cookie", "Set-Cookie",
lucia.createSessionCookie(session.id).serialize(), lucia.createSessionCookie(session.id).serialize(),
); );
} }
if (!session) { if (!session) {
appendHeader( appendHeader(
event, event.nativeEvent,
"Set-Cookie", "Set-Cookie",
lucia.createBlankSessionCookie().serialize(), lucia.createBlankSessionCookie().serialize(),
); );
} }
console.log(3);
event.nativeEvent.context.session = session; event.nativeEvent.context.session = session;
event.nativeEvent.context.user = user; event.nativeEvent.context.user = user;
}, },

View file

@ -1,4 +1,4 @@
import { APIEvent } from "@solidjs/start/server/types"; import { APIEvent } from "@solidjs/start/server";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
import db from "~/drizzle"; import db from "~/drizzle";
import { guilds } from "~/drizzle/schema"; import { guilds } from "~/drizzle/schema";

View file

@ -1,4 +1,4 @@
import { APIEvent } from "@solidjs/start/server/types"; import { APIEvent } from "@solidjs/start/server";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
import db from "~/drizzle"; import db from "~/drizzle";
import { guilds, matches } from "~/drizzle/schema"; import { guilds, matches } from "~/drizzle/schema";
@ -40,8 +40,6 @@ export const GET = async (
if (!guild) return ErrorResponse("NOT_FOUND"); if (!guild) return ErrorResponse("NOT_FOUND");
if (guild.matches.length < 1) return Res("NO_CONTENT", null);
return Res("OK", { return Res("OK", {
matches: buildMatches(guild.matches), matches: buildMatches(guild.matches),
timezone: guild.timezone, timezone: guild.timezone,

View file

@ -1,4 +1,4 @@
import { APIEvent } from "@solidjs/start/server/types"; import { APIEvent } from "@solidjs/start/server";
import { and, eq } from "drizzle-orm"; import { and, eq } from "drizzle-orm";
import db from "~/drizzle"; import db from "~/drizzle";
import { guilds, tpMessages } from "~/drizzle/schema"; import { guilds, tpMessages } from "~/drizzle/schema";

View file

@ -1,5 +1,5 @@
import { createId } from "@paralleldrive/cuid2"; import { createId } from "@paralleldrive/cuid2";
import { APIEvent } from "@solidjs/start/server/types"; import { APIEvent } from "@solidjs/start/server";
import { OAuth2RequestError } from "arctic"; import { OAuth2RequestError } from "arctic";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
import httpStatus from "http-status"; import httpStatus from "http-status";

View file

@ -1,4 +1,4 @@
import { APIEvent } from "@solidjs/start/server/types"; import { APIEvent } from "@solidjs/start/server";
import { generateState } from "arctic"; import { generateState } from "arctic";
import httpStatus from "http-status"; import httpStatus from "http-status";
import { setCookie } from "vinxi/http"; import { setCookie } from "vinxi/http";

View file

@ -1,4 +1,4 @@
import { APIEvent } from "@solidjs/start/server/types"; import { APIEvent } from "@solidjs/start/server";
import httpStatus from "http-status"; import httpStatus from "http-status";
import { appendHeader } from "vinxi/http"; import { appendHeader } from "vinxi/http";
import { lucia } from "~/lib/auth"; import { lucia } from "~/lib/auth";

View file

@ -1,4 +1,4 @@
import { APIEvent } from "@solidjs/start/server/types"; import { APIEvent } from "@solidjs/start/server";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
import db from "~/drizzle"; import db from "~/drizzle";
import { guilds } from "~/drizzle/schema"; import { guilds } from "~/drizzle/schema";