Add /api/v1/instance

This commit is contained in:
Alex Gleason 2023-03-04 20:19:57 -06:00
parent d855c05fac
commit 484a396a64
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
4 changed files with 53 additions and 2 deletions

45
src/api/instance.ts Normal file
View File

@ -0,0 +1,45 @@
import { LOCAL_DOMAIN, POST_CHAR_LIMIT } from '@/config.ts';
import type { Context } from '@/deps.ts';
function instanceController(c: Context) {
const { host } = new URL(LOCAL_DOMAIN);
return c.json({
uri: host,
title: 'Nostrverse',
description: 'An adapter between Mastodon API and Nostr.',
short_description: 'An adapter between Mastodon API and Nostr.',
registrations: false,
max_toot_chars: POST_CHAR_LIMIT,
configuration: {
media_attachments: {
image_size_limit: 100000000,
video_size_limit: 100000000,
},
polls: {
max_characters_per_option: 0,
max_expiration: 0,
max_options: 0,
min_expiration: 0,
},
statuses: {
max_characters: POST_CHAR_LIMIT,
max_media_attachments: 20,
},
},
languages: ['en'],
stats: {
domain_count: 0,
status_count: 0,
user_count: 0,
},
urls: {
streaming_api: `wss://${host}`,
},
version: '0.0.0 (compatible; Nostrverse 0.0.1)',
rules: [],
});
}
export default instanceController;

View File

@ -1,7 +1,9 @@
import { Hono } from '@/deps.ts';
import instanceController from './api/instance.ts';
const app = new Hono();
app.get('/', (c) => c.text('Hono!'));
app.get('/api/v1/instance', instanceController);
export default app;

2
src/config.ts Normal file
View File

@ -0,0 +1,2 @@
export const LOCAL_DOMAIN = Deno.env.get('LOCAL_DOMAIN') || 'http://localhost:8000';
export const POST_CHAR_LIMIT = Number(Deno.env.get('POST_CHAR_LIMIT') || 5000);

View File

@ -1 +1,3 @@
export { Hono } from 'https://deno.land/x/hono@v3.0.2/mod.ts';
import { Context, Hono } from 'https://deno.land/x/hono@v3.0.2/mod.ts';
export { Hono };
export type { Context };