Created Frontend and backend server and using claude to deploy db.ts and env.ts

This commit is contained in:
Mosiur Rahman
2026-04-20 16:03:37 +06:00
commit cff98994fd
6 changed files with 2169 additions and 0 deletions

0
server/src/config/db.ts Normal file
View File

21
server/src/config/env.ts Normal file
View File

@@ -0,0 +1,21 @@
import dotenv from "dotenv"
dotenv.config();
// This function validates that required env vars exist at startup
// Your app crashes immediately with a clear message — not silently later
const getEnvVar = (key: string): string => {
const value = process.env[key];
if (!value) {
throw new Error(`Missing required Environment Variable: ${key}`)
}
return value;
}
export const ENV = {
PORT: process.env.PORT || '5000',
MONGO_URI: getEnvVar('MONGO_URI'),
JWT_SECRET: getEnvVar('JWT_SECRET'),
NODE_ENV: process.env.NODE_ENV || 'development',
}