mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 22:09:16 +01:00
refactor(api): ♻️ Move to Hono for HTTP
This commit is contained in:
parent
2237be3689
commit
826a260e90
155 changed files with 7226 additions and 6077 deletions
|
|
@ -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: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue