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,4 +1,3 @@
|
|||
import { response } from "@/response";
|
||||
import { createMiddleware } from "@hono/hono/factory";
|
||||
import { getLogger } from "@logtape/logtape";
|
||||
import type { SocketAddress } from "bun";
|
||||
|
|
@ -34,7 +33,7 @@ export const bait = createMiddleware(async (context, next) => {
|
|||
if (requestIp?.address) {
|
||||
for (const ip of config.http.bait.bait_ips) {
|
||||
if (matches(ip, requestIp.address)) {
|
||||
return response(file);
|
||||
return context.newResponse(file.stream());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +43,7 @@ export const bait = createMiddleware(async (context, next) => {
|
|||
|
||||
for (const agent of config.http.bait.bait_user_agents) {
|
||||
if (new RegExp(agent).test(ua)) {
|
||||
return response(file);
|
||||
return context.newResponse(file.stream());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue