feat(store): 添加门店、门店验证
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { loadEnvFile } from 'node:process';
|
||||
|
||||
for (const directory of [process.cwd(), resolve(process.cwd(), '..'), resolve(process.cwd(), '../..')]) {
|
||||
const path = resolve(directory, '.env');
|
||||
if (existsSync(path)) {
|
||||
loadEnvFile(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function required(name: string): string {
|
||||
const value = process.env[name];
|
||||
if (!value) throw new Error(`${name} is required`);
|
||||
return value;
|
||||
}
|
||||
|
||||
export const workerConfig = {
|
||||
databaseUrl: required('DATABASE_URL'),
|
||||
redisUrl: required('REDIS_URL'),
|
||||
storeSecretEncryptionKey: required('STORE_SECRET_ENCRYPTION_KEY'),
|
||||
};
|
||||
Reference in New Issue
Block a user