Scratch space for learning atproto app development

tidy

Changed files
+18 -11
src
+7 -5
.env.template
···
# Environment Configuration
-
NODE_ENV="development" # Options: 'development', 'production'
-
PORT="8080" # The port your server will listen on
-
PUBLIC_URL="" # Set when deployed publicly, e.g. "https://mysite.com". Informs OAuth client id.
-
DB_PATH="db.sqlite" # The SQLite database path. Set as ":memory:" to use a temporary in-memory database.
+
NODE_ENV="development" # Options: 'development', 'production'
+
PORT="8080" # The port your server will listen on
+
PUBLIC_URL="" # Set when deployed publicly, e.g. "https://mysite.com". Informs OAuth client id.
+
DB_PATH="db.sqlite" # The SQLite database path. Set as ":memory:" to use a temporary in-memory database.
+
LOG_LEVEL="info" # Options: 'error', 'warn', 'info', 'debug'
+
# PDS_URL="https://my.pds" # The the default PDS for login and sign-ups
-
# Secrets: *MUST* set this in production
+
# Secrets bellow *MUST* be set in production
# May be generated with `openssl rand -base64 33`
# COOKIE_SECRET=""
+3 -4
src/env.ts
···
COOKIE_SECRET: str({ devDefault: '00000000000000000000000000000000' }),
PRIVATE_KEYS: envalidJsonWebKeys({ default: undefined }),
LOG_LEVEL: str({ default: 'info' }),
-
PDS_OWNER: str({ default: 'Bluesky' }),
-
PDS_URL: str({ default: 'https://bsky.social' }),
-
PLC_URL: str({ default: 'https://plc.directory' }),
-
FIREHOSE_URL: str({ default: 'wss://bsky.network' }),
+
PDS_URL: str({ default: undefined }),
+
PLC_URL: str({ default: undefined }),
+
FIREHOSE_URL: str({ default: undefined }),
})
+6 -1
src/pages/login.ts
···
}
function content({ error }: Props) {
+
const serviceName =
+
!env.PDS_URL || env.PDS_URL === 'https://bsky.social'
+
? 'Bluesky'
+
: env.PDS_URL
+
return html`<div id="root">
<div id="header">
<h1>Statusphere</h1>
···
</form>
<a href="/signup" class="button signup-cta">
-
Login or Sign up with a ${env.PDS_OWNER} account
+
Login or Sign up with a ${serviceName} account
</a>
${error ? html`<p>Error: <i>${error}</i></p>` : undefined}
+2 -1
src/routes.ts
···
'/signup',
handler(async (req: Request, res: Response) => {
try {
-
const url = await ctx.oauthClient.authorize(env.PDS_URL, {
+
const service = env.PDS_URL ?? 'https://bsky.social'
+
const url = await ctx.oauthClient.authorize(service, {
scope: 'atproto transition:generic',
})
res.redirect(url.toString())