refactor(api): ♻️ Move to Hono for HTTP

This commit is contained in:
Jesse Wierzbinski 2024-05-06 07:16:33 +00:00
parent 2237be3689
commit 826a260e90
No known key found for this signature in database
155 changed files with 7226 additions and 6077 deletions

View file

@ -1,5 +1,6 @@
import { apiRoute, applyConfig } from "@api";
import { applyConfig } from "@api";
import { jsonResponse } from "@response";
import type { Hono } from "hono";
import manifest from "~package.json";
export const meta = applyConfig({
@ -14,21 +15,18 @@ export const meta = applyConfig({
route: "/.well-known/nodeinfo/2.0",
});
/**
* ActivityPub nodeinfo 2.0 endpoint
*/
export default apiRoute(() => {
// TODO: Implement this
return jsonResponse({
version: "2.0",
software: { name: "lysand", version: manifest.version },
protocols: ["lysand"],
services: { outbound: [], inbound: [] },
usage: {
users: { total: 0, activeMonth: 0, activeHalfyear: 0 },
localPosts: 0,
},
openRegistrations: false,
metadata: {},
export default (app: Hono) =>
app.on(meta.allowedMethods, meta.route, async () => {
return jsonResponse({
version: "2.0",
software: { name: "lysand", version: manifest.version },
protocols: ["lysand"],
services: { outbound: [], inbound: [] },
usage: {
users: { total: 0, activeMonth: 0, activeHalfyear: 0 },
localPosts: 0,
},
openRegistrations: false,
metadata: {},
});
});
});

View file

@ -1,5 +1,7 @@
import { apiRoute, applyConfig } from "@api";
import { applyConfig } from "@api";
import { redirect } from "@response";
import type { Hono } from "hono";
import { config } from "~packages/config-manager";
export const meta = applyConfig({
allowedMethods: ["GET"],
@ -13,11 +15,10 @@ export const meta = applyConfig({
route: "/.well-known/nodeinfo",
});
export default apiRoute(async (req, matchedRoute, extraData) => {
const config = await extraData.configManager.getConfig();
return redirect(
new URL("/.well-known/nodeinfo/2.0", config.http.base_url),
301,
);
});
export default (app: Hono) =>
app.on(meta.allowedMethods, meta.route, async () => {
return redirect(
new URL("/.well-known/nodeinfo/2.0", config.http.base_url),
301,
);
});