Add nodeinfo

This commit is contained in:
Alex Gleason 2023-07-09 20:32:45 -05:00
parent 8894bb5513
commit 8fa6ac0a4c
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 59 additions and 0 deletions

View File

@ -28,6 +28,7 @@ import {
import { streamingController } from './controllers/api/streaming.ts';
import { indexController } from './controllers/site.ts';
import { hostMetaController } from './controllers/well-known/host-meta.ts';
import { nodeInfoController, nodeInfoSchemaController } from './controllers/well-known/nodeinfo.ts';
import { nostrController } from './controllers/well-known/nostr.ts';
import { webfingerController } from './controllers/well-known/webfinger.ts';
import { auth19, requireAuth } from './middleware/auth19.ts';
@ -61,8 +62,11 @@ app.use('*', cors({ origin: '*', exposeHeaders: ['link'] }), auth19, auth98());
app.get('/.well-known/webfinger', webfingerController);
app.get('/.well-known/host-meta', hostMetaController);
app.get('/.well-known/nodeinfo', nodeInfoController);
app.get('/.well-known/nostr.json', nostrController);
app.get('/nodeinfo/:version', nodeInfoSchemaController);
app.get('/api/v1/instance', instanceController);
app.get('/api/v1/apps/verify_credentials', appCredentialsController);

View File

@ -0,0 +1,55 @@
import { Conf } from '@/config.ts';
import type { AppController } from '@/app.ts';
const nodeInfoController: AppController = (c) => {
return c.json({
links: [
{
rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0',
href: Conf.local('/nodeinfo/2.0'),
},
{
rel: 'http://nodeinfo.diaspora.software/ns/schema/2.1',
href: Conf.local('/nodeinfo/2.1'),
},
],
});
};
const nodeInfoSchemaController: AppController = (c) => {
return c.json({
version: '2.1',
software: {
name: 'ditto',
version: '0.0.0',
repository: 'https://gitlab.com/soapbox-pub/ditto',
homepage: 'https://soapbox.pub',
},
protocols: [
'activitypub',
],
services: {
inbound: [],
outbound: [],
},
openRegistrations: false,
usage: {
users: {
total: 0,
activeMonth: 0,
activeHalfyear: 0,
},
localPosts: 0,
localComments: 0,
},
metadata: {
features: [
'nip05',
'nostr_bridge',
],
},
});
};
export { nodeInfoController, nodeInfoSchemaController };