Scaffold project and implement config, DB schema/queries
- Set up package.json (ESM, scripts), tsconfig.json, vitest.config.ts - Install runtime and dev dependencies - Add CLAUDE.md with architecture notes and code quality rules - Config module with env var parsing and JWT_SECRET validation - DB schema: users + files tables with FK cascade - DB queries: createUser, getUserBy*, createFile, getFileById, getFilesByUserId, deleteFile - Tests for config, db/users, db/files (15 tests passing) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
src/config.ts
Normal file
34
src/config.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
export interface Config {
|
||||
port: number;
|
||||
host: string;
|
||||
jwtSecret: string;
|
||||
jwtExpiry: string;
|
||||
dbPath: string;
|
||||
uploadDir: string;
|
||||
logFile: string;
|
||||
maxFileSize: number;
|
||||
baseUrl: string;
|
||||
cookieSecure: boolean;
|
||||
trustProxy: boolean;
|
||||
}
|
||||
|
||||
export function loadConfig(): Config {
|
||||
const jwtSecret = process.env.JWT_SECRET;
|
||||
if (!jwtSecret) {
|
||||
throw new Error('JWT_SECRET environment variable is required');
|
||||
}
|
||||
|
||||
return {
|
||||
port: parseInt(process.env.PORT ?? '3000', 10),
|
||||
host: process.env.HOST ?? '0.0.0.0',
|
||||
jwtSecret,
|
||||
jwtExpiry: process.env.JWT_EXPIRY ?? '7d',
|
||||
dbPath: process.env.DB_PATH ?? './data/nanodrop.db',
|
||||
uploadDir: process.env.UPLOAD_DIR ?? './data/uploads',
|
||||
logFile: process.env.LOG_FILE ?? './data/nanodrop.log',
|
||||
maxFileSize: parseInt(process.env.MAX_FILE_SIZE ?? '104857600', 10),
|
||||
baseUrl: process.env.BASE_URL ?? 'http://localhost:3000',
|
||||
cookieSecure: process.env.COOKIE_SECURE === 'true',
|
||||
trustProxy: process.env.TRUST_PROXY === 'true',
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user