Monorepo for Wisp.place. A static site hosting service built on top of the AT Protocol.
1import { Elysia } from 'elysia' 2import { cors } from '@elysiajs/cors' 3import { staticPlugin } from '@elysiajs/static' 4import { openapi, fromTypes } from '@elysiajs/openapi' 5 6import type { Config } from './lib/types' 7import { BASE_HOST } from './lib/constants' 8import { 9 createClientMetadata, 10 getOAuthClient, 11 getCurrentKeys 12} from './lib/oauth-client' 13import { authRoutes } from './routes/auth' 14import { wispRoutes } from './routes/wisp' 15 16const config: Config = { 17 domain: (Bun.env.DOMAIN ?? `https://${BASE_HOST}`) as `https://${string}`, 18 clientName: Bun.env.CLIENT_NAME ?? 'PDS-View' 19} 20 21const client = await getOAuthClient(config) 22 23export const app = new Elysia() 24 .use( 25 openapi({ 26 references: fromTypes() 27 }) 28 ) 29 .use( 30 await staticPlugin({ 31 prefix: '/' 32 }) 33 ) 34 .use(authRoutes(client)) 35 .use(wispRoutes(client)) 36 .get('/client-metadata.json', (c) => { 37 return createClientMetadata(config) 38 }) 39 .get('/jwks.json', (c) => { 40 const keys = getCurrentKeys() 41 if (!keys.length) return { keys: [] } 42 43 return { 44 keys: keys.map((k) => { 45 const jwk = k.publicJwk ?? k 46 const { ...pub } = jwk 47 return pub 48 }) 49 } 50 }) 51 .use(cors()) 52 .listen(8000) 53 54console.log( 55 `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}` 56)