forked from lobehub/lobe-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor: refactor to serverDB ENV (lobehub#2612)
- Loading branch information
Showing
6 changed files
with
30 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* eslint-disable sort-keys-fix/sort-keys-fix , typescript-sort-keys/interface */ | ||
import { createEnv } from '@t3-oss/env-nextjs'; | ||
import { z } from 'zod'; | ||
|
||
export const getServerDBConfig = () => { | ||
return createEnv({ | ||
client: { | ||
NEXT_PUBLIC_ENABLED_SERVER_SERVICE: z.boolean(), | ||
}, | ||
runtimeEnv: { | ||
NEXT_PUBLIC_ENABLED_SERVER_SERVICE: process.env.NEXT_PUBLIC_SERVICE_MODE === 'server', | ||
}, | ||
}); | ||
}; | ||
|
||
export const serverDBEnv = getServerDBConfig(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,22 @@ | ||
/** | ||
* the client config is only used in Vercel deployment | ||
*/ | ||
|
||
/* eslint-disable sort-keys-fix/sort-keys-fix , typescript-sort-keys/interface */ | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace NodeJS { | ||
interface ProcessEnv { | ||
NEXT_PUBLIC_DEVELOPER_DEBUG: string; | ||
NEXT_PUBLIC_I18N_DEBUG: string; | ||
NEXT_PUBLIC_I18N_DEBUG_BROWSER: string; | ||
NEXT_PUBLIC_I18N_DEBUG_SERVER: string; | ||
|
||
NEXT_PUBLIC_DEVELOPER_DEBUG: string; | ||
|
||
NEXT_PUBLIC_SERVICE_MODE?: 'server' | 'browser'; | ||
NEXT_PUBLIC_I18N_DEBUG_SERVER: string; | ||
} | ||
} | ||
} | ||
|
||
export const getClientConfig = () => ({ | ||
ENABLED_SERVER_SERVICE: process.env.NEXT_PUBLIC_SERVICE_MODE === 'server', | ||
export const getDebugConfig = () => ({ | ||
// developer debug mode | ||
DEBUG_MODE: process.env.NEXT_PUBLIC_DEVELOPER_DEBUG === '1', | ||
|
||
// i18n debug mode | ||
I18N_DEBUG: process.env.NEXT_PUBLIC_I18N_DEBUG === '1', | ||
I18N_DEBUG_BROWSER: process.env.NEXT_PUBLIC_I18N_DEBUG_BROWSER === '1', | ||
I18N_DEBUG_SERVER: process.env.NEXT_PUBLIC_I18N_DEBUG_SERVER === '1', | ||
|
||
// developer debug mode | ||
DEBUG_MODE: process.env.NEXT_PUBLIC_DEVELOPER_DEBUG === '1', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import pkg from '@/../package.json'; | ||
import { getClientConfig } from '@/config/client'; | ||
import { getServerDBConfig } from '@/config/db'; | ||
|
||
export const CURRENT_VERSION = pkg.version; | ||
|
||
export const isServerMode = getClientConfig().ENABLED_SERVER_SERVICE; | ||
export const isServerMode = getServerDBConfig().NEXT_PUBLIC_ENABLED_SERVER_SERVICE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters