chore: strengthen backend eslint profile
This commit is contained in:
@@ -7,12 +7,12 @@ export interface Environment {
|
||||
DATABASE_URL: string;
|
||||
FRONTEND_ORIGIN: string;
|
||||
JWT_SECRET: string;
|
||||
LOG_LEVEL: 'debug' | 'error' | 'info' | 'warn';
|
||||
PORT: number;
|
||||
TOKEN_ENCRYPTION_KEY: string;
|
||||
TBANK_CA_CERT_PATH?: string;
|
||||
TBANK_GRPC_ENDPOINT: string;
|
||||
TBANK_RATE_LIMIT_PER_SECOND: number;
|
||||
LOG_LEVEL: 'debug' | 'info' | 'warn' | 'error';
|
||||
TOKEN_ENCRYPTION_KEY: string;
|
||||
}
|
||||
|
||||
export function validateEnv(config: Record<string, unknown>): Environment {
|
||||
@@ -71,7 +71,7 @@ export function validateEnv(config: Record<string, unknown>): Environment {
|
||||
|
||||
if (
|
||||
typeof tokenEncryptionKey !== 'string' ||
|
||||
!/^[A-Za-z0-9+/]+={0,2}$/.test(tokenEncryptionKey) ||
|
||||
!/^[A-Z0-9+/]+={0,2}$/i.test(tokenEncryptionKey) ||
|
||||
Buffer.from(tokenEncryptionKey, 'base64').length !== TOKEN_KEY_BYTES
|
||||
) {
|
||||
throw new Error(
|
||||
@@ -92,7 +92,7 @@ export function validateEnv(config: Record<string, unknown>): Environment {
|
||||
throw new Error('TBANK_CA_CERT_PATH must be a file path');
|
||||
}
|
||||
|
||||
if (!['debug', 'info', 'warn', 'error'].includes(logLevel as string)) {
|
||||
if (!['debug', 'error', 'info', 'warn'].includes(logLevel as string)) {
|
||||
throw new Error('LOG_LEVEL must be debug, info, warn, or error');
|
||||
}
|
||||
|
||||
@@ -102,9 +102,9 @@ export function validateEnv(config: Record<string, unknown>): Environment {
|
||||
JWT_SECRET: jwtSecret,
|
||||
PORT: parsedPort,
|
||||
TOKEN_ENCRYPTION_KEY: tokenEncryptionKey,
|
||||
...(typeof tbankCaCertPath === 'string' && tbankCaCertPath
|
||||
? { TBANK_CA_CERT_PATH: tbankCaCertPath }
|
||||
: {}),
|
||||
...(typeof tbankCaCertPath === 'string' && tbankCaCertPath ?
|
||||
{ TBANK_CA_CERT_PATH: tbankCaCertPath } :
|
||||
{}),
|
||||
TBANK_GRPC_ENDPOINT: tbankEndpoint,
|
||||
TBANK_RATE_LIMIT_PER_SECOND: parsedTbankRateLimit,
|
||||
LOG_LEVEL: logLevel as Environment['LOG_LEVEL'],
|
||||
|
||||
Reference in New Issue
Block a user