allow limiting video-comments rss feeds to an account or video channel
[oweals/peertube.git] / server / controllers / webfinger.ts
1 import * as cors from 'cors'
2 import * as express from 'express'
3 import { asyncMiddleware } from '../middlewares'
4 import { webfingerValidator } from '../middlewares/validators'
5
6 const webfingerRouter = express.Router()
7
8 webfingerRouter.use(cors())
9
10 webfingerRouter.get('/.well-known/webfinger',
11   asyncMiddleware(webfingerValidator),
12   webfingerController
13 )
14
15 // ---------------------------------------------------------------------------
16
17 export {
18   webfingerRouter
19 }
20
21 // ---------------------------------------------------------------------------
22
23 function webfingerController (req: express.Request, res: express.Response) {
24   const actor = res.locals.actorUrl
25
26   const json = {
27     subject: req.query.resource,
28     aliases: [ actor.url ],
29     links: [
30       {
31         rel: 'self',
32         type: 'application/activity+json',
33         href: actor.url
34       }
35     ]
36   }
37
38   return res.json(json)
39 }