Files
backspace/packages/server/src/routes/instance.ts
T
Jannis Braun f481e1fe9e license: relicense to AGPL-3.0-only with commercial dual-license
- LICENSE -> verbatim GNU AGPL-3.0; add LICENSE-COMMERCIAL.md + SECURITY.md
- CLA -> exclusive-license grant (contributors keep copyright); add README
  anti-rugpull covenant + relicense record
- NOTICE / README / CONTRIBUTING / CLAUDE.md / package.json x5 updated;
  contact routed through GitHub (no email placeholders)
- AGPL section 13 source offer: operator-configurable BACKSPACE_SOURCE_URL +
  build-injected commit; sourceCodeUrl+commit on /api/instance/info;
  SourceCodeLink on login/register/settings/desktop; docs + .env.example updated
2026-07-01 16:38:22 +02:00

35 lines
1.3 KiB
TypeScript

import type { FastifyInstance } from 'fastify';
import { eq } from 'drizzle-orm';
import { getDb, schema } from '../db/index.js';
import { config } from '../config.js';
import type { InstanceInfoResponse } from '@backspace/shared';
const BACKSPACE_VERSION = '1.0.0';
export async function instanceRoutes(app: FastifyInstance): Promise<void> {
app.get('/api/instance/info', async (_request, reply) => {
const db = getDb();
const settings = db.select().from(schema.instanceSettings).where(eq(schema.instanceSettings.id, 1)).get();
const instanceName = settings?.instanceName ?? 'Backspace';
// DB setting overrides env var if explicitly set by admin
const registrationOpen = settings?.registrationOpen !== null && settings?.registrationOpen !== undefined
? settings.registrationOpen === 1
: config.registrationOpen;
const response: InstanceInfoResponse = {
name: instanceName,
version: BACKSPACE_VERSION,
registrationOpen,
federatedRegistrationOpen: settings?.federatedRegistrationOpen === 1,
// AGPL-3.0 § 13: advertise the source of the running version to every
// network user (and federated peer) — public/unauthenticated by design.
sourceCodeUrl: config.sourceCodeUrl,
commit: config.commit,
};
return reply.code(200).send(response);
});
}