show.js (457B)
1 import { app } from '../../app.js'; 2 import { realmMetadata, resolveRealm } from '../../lib/realm.js'; 3 4 export default { 5 method: 'get', 6 path: '/api/v1/realm', 7 name: 'realm.show', 8 async handler(req) { 9 const url = new URL(req.url, 'http://localhost'); 10 const realm = await resolveRealm({ 11 host: req.headers.host, 12 slug: url.searchParams.get('realm') || undefined, 13 }); 14 return new app.HttpOk(await realmMetadata(realm)); 15 }, 16 };