import { Hono } from "hono";
import { createATProtoOAuth } from "@tijs/atproto-oauth";
import { MemoryStorage } from "@tijs/atproto-storage";
import { LoginForm, SiteLayout } from "./components.tsx";
const app = new Hono();
export const oauth = createATProtoOAuth({
baseUrl: Deno.env.get("BASE_URL")!,
appName: "Pedro",
cookieSecret: Deno.env.get("COOKIE_SECRET")!,
storage: new MemoryStorage(),
sessionTtl: 60 * 60 * 24 * 14, // 14 days
});
app.get("/login", (c) => oauth.handleLogin(c.req.raw));
app.get("/oauth/callback", (c) => oauth.handleCallback(c.req.raw));
app.get("/oauth-client-metadata.json", () => oauth.handleClientMetadata());
app.post("/api/auth/logout", async (c) => {
const res = await oauth.handleLogout(c.req.raw)
const { success } = await res.json();
if (success) {
return c.html(
Error: Logout unsuccessful
) } }); // Routes app.get("/", (c) => { return c.html(Ask questions, share opinions, vote together
No profile logged in
PDS: {session.pdsUrl}
DID: {session.did}