refactor: create getCurrentDomain helper function
This commit is contained in:
@@ -8,6 +8,7 @@ import { z } from "zod";
|
||||
import { Case, changeStringCase } from "~/libs/changeStringCase";
|
||||
import type { AdminSdkCredentials } from "~/libs/fcm/getGoogleAuthToken";
|
||||
import { sendFcmMessage } from "~/libs/fcm/sendFcmMessage";
|
||||
import { getCurrentDomain } from "~/libs/getCurrentDomain";
|
||||
import { verifyQstashHeader } from "~/libs/qstash/verifyQstashHeader";
|
||||
import { readEnvVariable } from "~/libs/readEnvVariable";
|
||||
import { getTokensSubscribedToTitle } from "~/models/token";
|
||||
@@ -42,7 +43,7 @@ app.post(
|
||||
return c.json(ErrorResponse, { status: 401 });
|
||||
}
|
||||
|
||||
const domain = c.req.url.replace(c.req.path, "");
|
||||
const domain = getCurrentDomain(c.req);
|
||||
const { success, result: fetchEpisodesResult } = await fetch(
|
||||
`${domain}/episodes/${aniListId}`,
|
||||
).then((res) => res.json<EpisodesResponseSchema>());
|
||||
|
||||
5
src/libs/getCurrentDomain.ts
Normal file
5
src/libs/getCurrentDomain.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { HonoRequest } from "hono";
|
||||
|
||||
export function getCurrentDomain(req: HonoRequest) {
|
||||
return req.url.replace(req.path, "");
|
||||
}
|
||||
Reference in New Issue
Block a user