refactor(api): ♻️ Remove old redirect() and response() in favour of Hono's builtins

This commit is contained in:
Jesse Wierzbinski 2024-08-28 17:01:56 +02:00
parent 691716f7eb
commit 69d7d50239
No known key found for this signature in database
20 changed files with 188 additions and 174 deletions

View file

@ -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());
}
}