Rewrite with modern stack
This commit is contained in:
parent
855c61c740
commit
1f1f20ffd6
69 changed files with 17771 additions and 1589 deletions
43
backend/src/config/env.ts
Normal file
43
backend/src/config/env.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
export const config = {
|
||||
port: parseInt(process.env.PORT || '3001'),
|
||||
host: process.env.HOST || 'localhost',
|
||||
nodeEnv: process.env.NODE_ENV || 'development',
|
||||
jwtSecret: process.env.JWT_SECRET || 'your-super-secret-jwt-key-change-in-production',
|
||||
corsOrigin: process.env.CORS_ORIGIN ? process.env.CORS_ORIGIN.split(',') : ['http://localhost:3000'],
|
||||
|
||||
// Rate limiting
|
||||
rateLimits: {
|
||||
pixelsPerMinute: parseInt(process.env.RATE_LIMIT_PIXELS_PER_MINUTE || '60'),
|
||||
pixelsPerHour: parseInt(process.env.RATE_LIMIT_PIXELS_PER_HOUR || '1000'),
|
||||
cursorUpdatesPerSecond: parseInt(process.env.RATE_LIMIT_CURSOR_PER_SECOND || '10'),
|
||||
},
|
||||
|
||||
// Canvas settings
|
||||
canvas: {
|
||||
maxSize: parseInt(process.env.MAX_CANVAS_SIZE || '10000'),
|
||||
defaultSize: parseInt(process.env.DEFAULT_CANVAS_SIZE || '1000'),
|
||||
chunkSize: parseInt(process.env.CHUNK_SIZE || '64'),
|
||||
},
|
||||
|
||||
// Redis settings
|
||||
redis: {
|
||||
url: process.env.REDIS_URL || 'redis://localhost:6379',
|
||||
keyPrefix: process.env.REDIS_KEY_PREFIX || 'gaplace:',
|
||||
},
|
||||
|
||||
// Logging
|
||||
logLevel: process.env.LOG_LEVEL || 'info',
|
||||
} as const;
|
||||
|
||||
export function validateConfig(): void {
|
||||
const required = ['JWT_SECRET'];
|
||||
const missing = required.filter(key => !process.env[key]);
|
||||
|
||||
if (missing.length > 0 && config.nodeEnv === 'production') {
|
||||
throw new Error(`Missing required environment variables: ${missing.join(', ')}`);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue