Skip to content

Commit 3c96ea5

Browse files
committed
fix(forms): session name
1 parent 4a32211 commit 3c96ea5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

packages/forms/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
<div align="center">
2+
13
# Astro Forms
24

3-
<img src ="https://raw.githubusercontent.com/withastro-utils/forms/main/assets/logo.webp" width="100px"/><br/>
5+
<img src="../../assets/logo.rounded.png" alt="Astro Utils" height="300px"/>
6+
</div>
47

58

6-
Reactive forms for Astro without any JavaScript!
9+
> Reactive forms for Astro without any JavaScript!
710
811
### Why use this?
912
- Allow client side & server side validation & parsing (number, boolean...)
@@ -134,16 +137,16 @@ You can also use this as a simple on click hook
134137
```astro
135138
---
136139
import { Button } from "@astro-utils/forms/forms.js";
137-
const { asSession } = Astro.locals
140+
const { session } = Astro.locals
138141
139142
function increaseCounter() {
140-
asSession.counter ??= 0
141-
asSession.counter++
143+
session.counter ??= 0
144+
session.counter++
142145
}
143146
---
144147
<Layout>
145148
<Button onClick={increaseCounter}>++</Button>
146-
{asSession.counter}
149+
{session.counter}
147150
<Layout/>
148151
```
149152

packages/forms/src/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function astroForms(settings: Partial<FormsSettings> = {}){
3131

3232
return async function onRequest ({ locals, request, cookies }: APIContext , next: MiddlewareNextResponse) {
3333
const session = new JWTSession(cookies);
34-
locals.amSession = session.sessionData;
34+
locals.session = session.sessionData;
3535

3636
await validateFrom({cookies, locals, request}, FORM_OPTIONS.csrf);
3737
const response = await next();

0 commit comments

Comments
 (0)