Skip to content

Commit 4a763e5

Browse files
authored
fix: move getEnv into function for proper initialization (#309)
1 parent edbcac5 commit 4a763e5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

server/src/services/favicon.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,24 @@ import { setup } from "../setup";
55
import { createS3Client } from "../utils/s3";
66
import path from "path";
77

8-
const env = getEnv();
98
// @see https://developers.cloudflare.com/images/url-format#supported-formats-and-limitations
109
export const FAVICON_ALLOWED_TYPES: { [key: string]: string } = {
1110
"image/jpeg": ".jpg",
1211
"image/png": ".png",
1312
"image/gif": ".gif",
1413
"image/webp": ".webp",
1514
};
16-
export const faviconKey = path.join(env.S3_FOLDER || "", "favicon.webp");
15+
export function getFaviconKey() {
16+
const env = getEnv();
17+
return path.join(env.S3_FOLDER || "", "favicon.webp");
18+
}
1719

1820
export function FaviconService() {
21+
const env = getEnv();
1922
const s3 = createS3Client();
2023
const bucket = env.S3_BUCKET;
2124
const accessHost = env.S3_ACCESS_HOST || env.S3_ENDPOINT;
25+
const faviconKey = getFaviconKey();
2226
return new Elysia({ aot: false })
2327
.use(setup())
2428
.get("/favicon", async ({ set }) => {

server/src/services/rss.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { PutObjectCommand } from "@aws-sdk/client-s3";
22
import { and, desc, eq } from "drizzle-orm";
33
import { drizzle } from "drizzle-orm/d1";
44
import Elysia from "elysia";
5-
import { FAVICON_ALLOWED_TYPES, faviconKey } from "./favicon";
5+
import { FAVICON_ALLOWED_TYPES, getFaviconKey } from "./favicon";
66
import { Feed } from "feed";
77
import path from 'path';
88
import rehypeStringify from "rehype-stringify";
@@ -62,6 +62,7 @@ export async function rssCrontab(env: Env) {
6262
const frontendUrl = `${env.FRONTEND_URL.startsWith("http://") || env.FRONTEND_URL.startsWith("https://") ? "" : "https://"}${env.FRONTEND_URL}`;
6363
const db = drizzle(env.DB, { schema: schema });
6464
const accessHost = env.S3_ACCESS_HOST || env.S3_ENDPOINT;
65+
const faviconKey = getFaviconKey();
6566

6667
let feedConfig: any = {
6768
title: env.RSS_TITLE,

0 commit comments

Comments
 (0)