mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(api): ♻️ Remove old redirect() and response() in favour of Hono's builtins
This commit is contained in:
parent
691716f7eb
commit
69d7d50239
20 changed files with 188 additions and 174 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { apiRoute, applyConfig } from "@/api";
|
||||
import { xmlResponse } from "@/response";
|
||||
import { config } from "~/packages/config-manager";
|
||||
|
||||
export const meta = applyConfig({
|
||||
|
|
@ -15,8 +14,9 @@ export const meta = applyConfig({
|
|||
});
|
||||
|
||||
export default apiRoute((app) =>
|
||||
app.on(meta.allowedMethods, meta.route, () => {
|
||||
return xmlResponse(
|
||||
app.on(meta.allowedMethods, meta.route, (context) => {
|
||||
context.header("Content-Type", "application/xrd+xml");
|
||||
return context.body(
|
||||
`<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Link rel="lrdd" template="${new URL(
|
||||
"/.well-known/webfinger",
|
||||
config.http.base_url,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { apiRoute, applyConfig } from "@/api";
|
||||
import { redirect } from "@/response";
|
||||
import { config } from "~/packages/config-manager";
|
||||
|
||||
export const meta = applyConfig({
|
||||
|
|
@ -15,9 +14,12 @@ export const meta = applyConfig({
|
|||
});
|
||||
|
||||
export default apiRoute((app) =>
|
||||
app.on(meta.allowedMethods, meta.route, () => {
|
||||
return redirect(
|
||||
new URL("/.well-known/nodeinfo/2.0", config.http.base_url),
|
||||
app.on(meta.allowedMethods, meta.route, (context) => {
|
||||
return context.redirect(
|
||||
new URL(
|
||||
"/.well-known/nodeinfo/2.0",
|
||||
config.http.base_url,
|
||||
).toString(),
|
||||
301,
|
||||
);
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue