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
37import express from 'express' ;
48import { 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