Skip to content

Commit fef8b2f

Browse files
committed
updated cookie handling
1 parent 6ff987f commit fef8b2f

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

app/composables/useAppCookies.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { CookieOptions } from "#app";
2+
import type { H3Event } from "h3";
23

34
type CookieOptionsWithoutReadonly<T> = CookieOptions<T> & {
45
readonly?: false;
@@ -15,29 +16,21 @@ class AppCookie<T extends string | null | undefined> {
1516
return useCookie(this.name);
1617
}
1718

19+
getServerSide(event: H3Event) {
20+
return getCookie(event, this.name);
21+
}
22+
1823
set(value: T) {
1924
useCookie(this.name, this.options as CookieOptionsWithoutReadonly<T> | undefined).value = value;
2025
}
2126

2227
}
2328

24-
class AppCookieHandler {
25-
26-
private constructor() {}
2729

28-
private static readonly cookies = {
30+
export function useAppCookies() {
31+
return {
2932

3033
sessionToken: new AppCookie<string | null>("dla_session_token"),
31-
34+
3235
} as const;
33-
34-
static getCookies() {
35-
return AppCookieHandler.cookies;
36-
}
37-
38-
}
39-
40-
41-
export function useAppCookies() {
42-
return AppCookieHandler.getCookies();
4336
}

0 commit comments

Comments
 (0)