From 3c96ea5ad722097df8da162f4f045af3c1ef9394 Mon Sep 17 00:00:00 2001 From: ido Date: Sat, 18 Nov 2023 18:46:05 +0200 Subject: [PATCH] fix(forms): session name --- packages/forms/README.md | 15 +++++++++------ packages/forms/src/middleware.ts | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/forms/README.md b/packages/forms/README.md index 3f47ed1..703c22d 100644 --- a/packages/forms/README.md +++ b/packages/forms/README.md @@ -1,9 +1,12 @@ +
+ # Astro Forms -
+Astro Utils +
-Reactive forms for Astro without any JavaScript! +> Reactive forms for Astro without any JavaScript! ### Why use this? - Allow client side & server side validation & parsing (number, boolean...) @@ -134,16 +137,16 @@ You can also use this as a simple on click hook ```astro --- import { Button } from "@astro-utils/forms/forms.js"; -const { asSession } = Astro.locals +const { session } = Astro.locals function increaseCounter() { - asSession.counter ??= 0 - asSession.counter++ + session.counter ??= 0 + session.counter++ } --- - {asSession.counter} + {session.counter} ``` diff --git a/packages/forms/src/middleware.ts b/packages/forms/src/middleware.ts index 8bbd51a..c2e4198 100644 --- a/packages/forms/src/middleware.ts +++ b/packages/forms/src/middleware.ts @@ -31,7 +31,7 @@ export default function astroForms(settings: Partial = {}){ return async function onRequest ({ locals, request, cookies }: APIContext , next: MiddlewareNextResponse) { const session = new JWTSession(cookies); - locals.amSession = session.sessionData; + locals.session = session.sessionData; await validateFrom({cookies, locals, request}, FORM_OPTIONS.csrf); const response = await next();