-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.ts
24 lines (19 loc) · 834 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
import twindPlugin from "$fresh/plugins/twind.ts";
import twindConfig from "./twind.config.ts";
import { supabase } from "lib/supabase.ts";
import { redis } from "lib/redis.ts";
supabase.auth.onAuthStateChange(async (event, session) => {
if (event == "SIGNED_IN" || event == "TOKEN_REFRESHED" && session != null) {
const { access_token, expires_in } = session!;
const stringified = JSON.stringify(session);
await redis.set(access_token, stringified, { ex: expires_in });
}
});
await start(manifest, { plugins: [twindPlugin(twindConfig)], port: 8080 });