example restaurant review app on atproto
1import { NodeOAuthClient } from "@atproto/oauth-client-node";
2import { StateStore, SessionStore } from "./storage";
3import { db } from "../drizzle/db";
4
5const IS_DEV = process.env.NODE_ENV === "development";
6const PUBLIC_URL = "https://fooodz.app";
7const LOCAL_URL = "http://[::1]:3000";
8const URL = IS_DEV ? LOCAL_URL : PUBLIC_URL;
9
10export const client = new NodeOAuthClient({
11 clientMetadata: {
12 client_name: "fooodz",
13 client_id: !IS_DEV
14 ? `${PUBLIC_URL}/client-metadata.json`
15 : `http://localhost?redirect_uri=${encodeURIComponent(
16 `${URL}/oauth/callback`,
17 )}&scope=${encodeURIComponent("atproto email profile account:email repo:app.fooodz.review")}`,
18 client_uri: URL,
19 redirect_uris: [`${URL}/oauth/callback`],
20 scope: "atproto email profile account:email repo:app.fooodz.review",
21 grant_types: ["authorization_code", "refresh_token"],
22 response_types: ["code"],
23 application_type: "web",
24 token_endpoint_auth_method: "none",
25 dpop_bound_access_tokens: true,
26 },
27 stateStore: new StateStore(db),
28 sessionStore: new SessionStore(db),
29});