Skip to content

Commit 58d1ca1

Browse files
authored
Merge pull request #181 from andypiper/nodeinfo-2.1
feat: add nodeinfo 2.1 document (parallel with 2.0).
2 parents 44c6775 + 6c238c1 commit 58d1ca1

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ app.use('/', routes.core);
128128
app.use('/api/inbox', cors(), routes.inbox);
129129
app.use('/.well-known/nodeinfo', routes.nodeinfo);
130130
app.use('/nodeinfo/2.0', routes.nodeinfo);
131+
app.use('/nodeinfo/2.1', routes.nodeinfo);
131132
app.use('/opensearch.xml', routes.opensearch);
132133

133134
app.listen(PORT, () => console.log(`App listening on port ${PORT}`));

src/routes/activitypub/nodeinfo.js

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// implementation of http://nodeinfo.diaspora.software/protocol.html
1+
// implementation of http://nodeinfo.diaspora.software/
2+
// TODO: activeMonth and activeHalfyear should be dynamic, currently static
3+
// TODO: enable override of nodeName and nodeDescription from settings
4+
// homepage and repository may want to be updated for user-specific forks
5+
// NB openRegistrations will always be false for a single-instance server
26

37
import express from 'express';
48
import { instanceType, instanceVersion } from '../../util.js';
@@ -15,6 +19,10 @@ router.get('/', async (req, res) => {
1519
rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0',
1620
href: `https://${domain}/nodeinfo/2.0`,
1721
},
22+
{
23+
rel: 'http://nodeinfo.diaspora.software/ns/schema/2.1',
24+
href: `https://${domain}/nodeinfo/2.1`,
25+
},
1826
],
1927
};
2028
res.json(thisNode);
@@ -24,7 +32,6 @@ router.get('/', async (req, res) => {
2432
const bookmarksDb = req.app.get('bookmarksDb');
2533
const bookmarkCount = await bookmarksDb.getBookmarkCount();
2634

27-
// TODO: activeMonth and activeHalfyear should be dynamic, currently static
2835
const nodeInfo = {
2936
version: 2.0,
3037
software: {
@@ -48,10 +55,45 @@ router.get('/', async (req, res) => {
4855
metadata: {},
4956
};
5057

51-
// spec requires setting this, majority of implementations
52-
// appear to not bother with it?
58+
// spec says servers *should* set this, majority of implementations
59+
// appear to not bother with this detail, but we'll do right by the spec
5360
res.type('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"');
61+
res.json(nodeInfo);
62+
}
63+
64+
if (req.originalUrl === '/nodeinfo/2.1') {
65+
const bookmarksDb = req.app.get('bookmarksDb');
66+
const bookmarkCount = await bookmarksDb.getBookmarkCount();
67+
68+
const nodeInfo = {
69+
version: 2.1,
70+
software: {
71+
name: instanceType,
72+
version: instanceVersion,
73+
repository: 'https://github.com/ckolderup/postmarks',
74+
homepage: 'https://postmarks.glitch.me',
75+
},
76+
protocols: ['activitypub'],
77+
services: {
78+
outbound: ['atom1.0'],
79+
inbound: [],
80+
},
81+
usage: {
82+
users: {
83+
total: 1,
84+
activeMonth: 1,
85+
activeHalfyear: 1,
86+
},
87+
localPosts: bookmarkCount,
88+
},
89+
openRegistrations: false,
90+
metadata: {
91+
nodeName: 'Postmarks',
92+
nodeDescription: 'A single-user bookmarking website designed to live on the Fediverse.',
93+
},
94+
};
5495

96+
res.type('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.1#"');
5597
res.json(nodeInfo);
5698
}
5799
});

0 commit comments

Comments
 (0)