2023-12-05 08:12:10 +01:00
|
|
|
import Router from "@koa/router";
|
2024-04-19 19:07:08 +02:00
|
|
|
import { config } from "@/config.js";
|
2024-05-05 19:20:39 +02:00
|
|
|
import { nodeinfo_2_0, nodeinfo_2_1 } from "backend-rs";
|
|
|
|
import { fromRustObject } from "@/prelude/undefined-to-null.js";
|
2019-02-05 09:42:55 +01:00
|
|
|
|
|
|
|
const router = new Router();
|
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
const nodeinfo2_1path = "/nodeinfo/2.1";
|
|
|
|
const nodeinfo2_0path = "/nodeinfo/2.0";
|
2019-02-05 09:42:55 +01:00
|
|
|
|
2023-01-09 22:36:31 +01:00
|
|
|
// to cleo: leave this http or bonks
|
2023-01-13 05:40:33 +01:00
|
|
|
export const links = [
|
|
|
|
{
|
|
|
|
rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
|
|
|
|
href: config.url + nodeinfo2_1path,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
|
|
|
|
href: config.url + nodeinfo2_0path,
|
|
|
|
},
|
|
|
|
];
|
2019-02-05 09:42:55 +01:00
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
router.get(nodeinfo2_1path, async (ctx) => {
|
2024-05-05 19:20:39 +02:00
|
|
|
ctx.body = fromRustObject(await nodeinfo_2_1());
|
|
|
|
ctx.set("Cache-Control", "public, max-age=3600");
|
2019-02-05 09:42:55 +01:00
|
|
|
});
|
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
router.get(nodeinfo2_0path, async (ctx) => {
|
2024-05-05 19:20:39 +02:00
|
|
|
ctx.body = fromRustObject(await nodeinfo_2_0());
|
|
|
|
ctx.set("Cache-Control", "public, max-age=3600");
|
2019-02-05 09:42:55 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
export default router;
|