From 2a3e232f559ad58f3352fac78ce552635a8cc554 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 30 Jan 2024 00:44:09 +0800 Subject: [PATCH] style: update env path in global env --- src/server/trpc/routers/global.ts | 9 +++++---- src/server/utils/env.ts | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/server/trpc/routers/global.ts b/src/server/trpc/routers/global.ts index f12a409..4f091a8 100644 --- a/src/server/trpc/routers/global.ts +++ b/src/server/trpc/routers/global.ts @@ -1,6 +1,7 @@ import { z } from 'zod'; import { publicProcedure, router } from '../trpc'; import { OPENAPI_TAG } from '../../utils/const'; +import { env } from '../../utils/env'; export const globalRouter = router({ config: publicProcedure @@ -23,10 +24,10 @@ export const globalRouter = router({ ) .query(async ({ input }) => { return { - allowRegister: checkEnvTrusty(process.env.ALLOW_REGISTER), - websiteId: process.env.WEBSITE_ID, - amapToken: process.env.AMAP_TOKEN, - mapboxToken: process.env.MAPBOX_TOKEN, + allowRegister: env.allowRegister, + websiteId: env.websiteId, + amapToken: env.amapToken, + mapboxToken: env.mapboxToken, }; }), }); diff --git a/src/server/utils/env.ts b/src/server/utils/env.ts index f5d8cb9..ce583ef 100644 --- a/src/server/utils/env.ts +++ b/src/server/utils/env.ts @@ -8,6 +8,8 @@ export const env = { ? Number(process.env.SANDBOX_MEMORY_LIMIT) : 16, // unit: MB dbDebug: checkEnvTrusty(process.env.DB_DEBUG), + amapToken: process.env.AMAP_TOKEN, + mapboxToken: process.env.MAPBOX_TOKEN, }; export function checkEnvTrusty(env: string | undefined): boolean {