From e839a5f61f0faa21ca8b4bd5767f7575d5e576ee Mon Sep 17 00:00:00 2001 From: polwex Date: Wed, 21 May 2025 14:00:28 +0700 Subject: the card flip animation is legit --- src/lib/server/cookie.ts | 52 +++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) (limited to 'src/lib/server/cookie.ts') diff --git a/src/lib/server/cookie.ts b/src/lib/server/cookie.ts index 30f215e..bbabd63 100644 --- a/src/lib/server/cookie.ts +++ b/src/lib/server/cookie.ts @@ -1,47 +1,41 @@ -import { - getCookie, - getSignedCookie, - setCookie, - setSignedCookie, - deleteCookie, -} from "hono/cookie"; +import { getHonoContext } from "waku/unstable_hono"; import cookie from "cookie"; -// console.log("db module path:", "@/lib/db"); -// console.log( -// "globalThis.__WAKU_MIDDLEWARE_CONTEXT_STORAGE__:", -// globalThis.__WAKU_MIDDLEWARE_CONTEXT_STORAGE__, -// ); import db from "../db"; import type { Middleware } from "waku/config"; -// XXX we would probably like to extend config. - const cookieMiddleware: Middleware = () => { console.log("cookieMiddleware executed"); return async (ctx, next) => { const cookies = cookie.parse(ctx.req.headers.cookie || ""); - console.log({ cookies }); const coki = cookies.sorlang; - if (!coki) { - if (ctx.req.url.pathname === "/login") return await next(); - ctx.res.status = 301; - ctx.res.headers = { - Location: "/login", - }; - } + // if (!coki) { + // if (ctx.req.url.pathname === "/login") return await next(); + // ctx.res.status = 301; + // ctx.res.headers = { + // Location: "/login", + // }; + // } if (coki) { const userRow = db.fetchCookie(coki); + console.log({ userRow }); if (userRow) ctx.data.user = { id: userRow.id, name: userRow.name }; - else { - if (ctx.req.url.pathname === "/login") return await next(); - ctx.res.status = 301; - ctx.res.headers = { - Location: "/login", - }; - } + // else { + // if (ctx.req.url.pathname === "/login") return await next(); + // ctx.res.status = 301; + // ctx.res.headers = { + // Location: "/login", + // }; + // } } await next(); + const hctx: any = getHonoContext(); + console.log("hono", hctx.lol); + console.log("ctx coki", ctx.data.cookie); + ctx.res.headers ||= {}; + if (ctx.data.cookie) + ctx.res.headers["set-cookie"] = ctx.data.cookie as string; + ctx.res.headers["set-lmao"] = "wtf man"; }; }; -- cgit v1.2.3