summaryrefslogtreecommitdiff
path: root/examples/ssr/src/models/user.ts
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2022-03-16 12:16:21 -0400
committerGravatar GitHub <noreply@github.com> 2022-03-16 12:16:21 -0400
commit4c25a1c2eacf897427a7d6dac3bf476ef56799de (patch)
treedb1d341557694e17a07027ebea160c89bad4813d /examples/ssr/src/models/user.ts
parent8f13b3d4068f0f017186fbc2dbd33a1427768ea4 (diff)
downloadastro-4c25a1c2eacf897427a7d6dac3bf476ef56799de.tar.gz
astro-4c25a1c2eacf897427a7d6dac3bf476ef56799de.tar.zst
astro-4c25a1c2eacf897427a7d6dac3bf476ef56799de.zip
Implements redirects, headers for SSR (#2798)
* Implements redirects, headers for SSR * Move away from an explicit Request * Properly handle endpoint routes in the build * chore(lint): ESLint fix * Update based on review comments Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'examples/ssr/src/models/user.ts')
-rw-r--r--examples/ssr/src/models/user.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/examples/ssr/src/models/user.ts b/examples/ssr/src/models/user.ts
new file mode 100644
index 000000000..ecd839d46
--- /dev/null
+++ b/examples/ssr/src/models/user.ts
@@ -0,0 +1,8 @@
+import lightcookie from 'lightcookie';
+
+
+export function isLoggedIn(request: Request): boolean {
+ const cookie = request.headers.get('cookie');
+ const parsed = lightcookie.parse(cookie);
+ return 'user-id' in parsed;
+}