initial commit
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
51
src/config/env.ts
Normal file
51
src/config/env.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
|
||||
function required(key: string): string {
|
||||
const val = process.env[key];
|
||||
if (!val) throw new Error(`Missing required env variable: ${key}`);
|
||||
return val;
|
||||
}
|
||||
|
||||
export const config = {
|
||||
port: parseInt(process.env.PORT || '3001', 10),
|
||||
host: process.env.HOST || '127.0.0.1',
|
||||
appEnv: process.env.APP_ENV || 'local',
|
||||
isProduction: process.env.APP_ENV === 'production',
|
||||
|
||||
db: {
|
||||
url: required('DATABASE_URL'),
|
||||
},
|
||||
|
||||
jwt: {
|
||||
secret: required('JWT_SECRET'),
|
||||
accessTokenExpiry: parseInt(process.env.ACCESS_TOKEN_EXPIRY || '900', 10),
|
||||
refreshTokenSessionExpiry: parseInt(process.env.REFRESH_TOKEN_SESSION_EXPIRY || '3600', 10),
|
||||
refreshTokenRememberExpiry: parseInt(process.env.REFRESH_TOKEN_REMEMBER_EXPIRY || '2592000', 10),
|
||||
},
|
||||
|
||||
totp: {
|
||||
encryptionKey: required('TOTP_ENCRYPTION_KEY'),
|
||||
},
|
||||
|
||||
nas: {
|
||||
path: process.env.NAS_PATH || 'Z:/02_PROJEKTY',
|
||||
maxUploadSize: parseInt(process.env.MAX_UPLOAD_SIZE || '52428800', 10),
|
||||
},
|
||||
|
||||
email: {
|
||||
contactTo: process.env.CONTACT_EMAIL_TO || '',
|
||||
contactFrom: process.env.CONTACT_EMAIL_FROM || '',
|
||||
smtpFrom: process.env.SMTP_FROM || '',
|
||||
},
|
||||
|
||||
cors: {
|
||||
origins: (process.env.CORS_ORIGINS || '').split(',').filter(Boolean),
|
||||
},
|
||||
|
||||
security: {
|
||||
maxLoginAttempts: 5,
|
||||
lockoutMinutes: 15,
|
||||
bcryptCost: 12,
|
||||
},
|
||||
} as const;
|
||||
Reference in New Issue
Block a user