@evanp/activitypub-bot 0.26.2 → 0.26.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,32 +5,35 @@ const router = express.Router()
5
5
 
6
6
  router.get('/', async (req, res) => {
7
7
  const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`
8
+ const sendJson = async () => {
9
+ const { formatter } = req.app.locals
10
+ const server = await as2.import({
11
+ '@context': [
12
+ 'https://www.w3.org/ns/activitystreams',
13
+ 'https://w3id.org/security/v1'
14
+ ],
15
+ id: formatter.format({ server: true }),
16
+ type: 'Service',
17
+ publicKey: formatter.format({ server: true, type: 'publickey' }),
18
+ url: {
19
+ type: 'Link',
20
+ mediaType: 'text/html',
21
+ href: fullUrl
22
+ }
23
+ })
24
+ const body = await server.export({ useOriginalContext: true })
25
+ res.status(200)
26
+ res.type(as2.mediaType)
27
+ res.json(body)
28
+ }
8
29
  res.format({
9
30
  html: async () => {
10
31
  const { indexFileName } = req.app.locals
11
32
  res.sendFile(indexFileName)
12
33
  },
13
- json: async () => {
14
- const { formatter } = req.app.locals
15
- const server = await as2.import({
16
- '@context': [
17
- 'https://www.w3.org/ns/activitystreams',
18
- 'https://w3id.org/security/v1'
19
- ],
20
- id: formatter.format({ server: true }),
21
- type: 'Service',
22
- publicKey: formatter.format({ server: true, type: 'publickey' }),
23
- url: {
24
- type: 'Link',
25
- mediaType: 'text/html',
26
- href: fullUrl
27
- }
28
- })
29
- const body = await server.export({ useOriginalContext: true })
30
- res.status(200)
31
- res.type(as2.mediaType)
32
- res.json(body)
33
- }
34
+ 'application/activity+json': sendJson,
35
+ 'application/ld+json': sendJson,
36
+ json: sendJson
34
37
  })
35
38
  })
36
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.26.2",
3
+ "version": "0.26.3",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",