denonbu-feed/src/well-known.ts

27 lines
620 B
TypeScript
Raw Normal View History

2023-05-11 23:43:47 +00:00
import express from 'express'
import { AppContext } from './config'
2023-05-11 23:43:47 +00:00
const makeRouter = (ctx: AppContext) => {
2023-05-11 23:43:47 +00:00
const router = express.Router()
router.get('/.well-known/did.json', (_req, res) => {
if (!ctx.cfg.serviceDid.endsWith(ctx.cfg.hostname)) {
return res.sendStatus(404)
}
2023-05-11 23:43:47 +00:00
res.json({
'@context': ['https://www.w3.org/ns/did/v1'],
id: ctx.cfg.serviceDid,
2023-05-11 23:43:47 +00:00
service: [
{
id: '#bsky_fg',
type: 'BskyFeedGenerator',
serviceEndpoint: `https://${ctx.cfg.hostname}`,
2023-05-11 23:43:47 +00:00
},
],
})
})
return router
}
export default makeRouter