feat: simplify environment configuration by hardcoding token TTLs and removing unnecessary variables
This commit is contained in:
@@ -4,9 +4,7 @@
|
||||
# Copy this file to .env and adjust values for your setup
|
||||
# =============================================================================
|
||||
|
||||
NODE_ENV=production
|
||||
PORT=3000
|
||||
DATABASE_URL=file:./data/medassist-ng.db
|
||||
CORS_ORIGINS=http://localhost:4174
|
||||
LOG_LEVEL=info
|
||||
|
||||
@@ -17,8 +15,6 @@ TZ=Europe/Berlin
|
||||
JWT_SECRET=CHANGE_ME_generate_with_openssl_rand_hex_32
|
||||
REFRESH_SECRET=CHANGE_ME_generate_with_openssl_rand_hex_32
|
||||
COOKIE_SECRET=CHANGE_ME_generate_with_openssl_rand_hex_32
|
||||
ACCESS_TOKEN_TTL_MIN=15
|
||||
REFRESH_TOKEN_TTL_DAYS=14
|
||||
|
||||
# SMTP (optional - for email notifications)
|
||||
SMTP_HOST=
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"start": "node dist/index.js",
|
||||
"migrate": "tsx src/db/migrate.ts",
|
||||
"lint": "echo 'add lint config'"
|
||||
"migrate": "tsx src/db/migrate.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fastify/cookie": "^10.0.1",
|
||||
|
||||
@@ -6,7 +6,7 @@ import dotenv from "dotenv";
|
||||
|
||||
dotenv.config({ path: process.env.DOTENV_PATH || ".env" });
|
||||
|
||||
const url = process.env.DATABASE_URL || "file:./data/medassist-ng.db";
|
||||
const url = "file:./data/medassist-ng.db";
|
||||
|
||||
// Ensure data directory exists before creating database
|
||||
if (url.startsWith("file:")) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import dotenv from "dotenv";
|
||||
|
||||
dotenv.config({ path: process.env.DOTENV_PATH || ".env" });
|
||||
|
||||
const url = process.env.DATABASE_URL || "file:./data/medassist-ng.db";
|
||||
const url = "file:./data/medassist-ng.db";
|
||||
|
||||
async function main() {
|
||||
console.log("Starting database setup...");
|
||||
|
||||
@@ -37,8 +37,9 @@ const app = Fastify({
|
||||
|
||||
const origins = env.CORS_ORIGINS.split(",").map((o) => o.trim()).filter(Boolean);
|
||||
|
||||
const accessTtlMinutes = parseInt(env.ACCESS_TOKEN_TTL_MIN, 10);
|
||||
const refreshTtlDays = parseInt(env.REFRESH_TOKEN_TTL_DAYS, 10);
|
||||
// Auth token TTLs (hardcoded - no need for user configuration)
|
||||
const accessTtlMinutes = 15; // Access token: 15 minutes
|
||||
const refreshTtlDays = 14; // Refresh token: 14 days
|
||||
|
||||
const baseCookieOptions: CookieSerializeOptions = {
|
||||
httpOnly: true,
|
||||
|
||||
@@ -4,16 +4,13 @@ import dotenv from "dotenv";
|
||||
dotenv.config({ path: process.env.DOTENV_PATH || ".env" });
|
||||
|
||||
const EnvSchema = z.object({
|
||||
NODE_ENV: z.enum(["development", "production", "test"]).default("development"),
|
||||
NODE_ENV: z.enum(["development", "production", "test"]).default("production"),
|
||||
PORT: z.string().transform((v) => parseInt(v, 10)).default("3000"),
|
||||
DATABASE_URL: z.string().default("file:./data/medassist-ng.db"),
|
||||
CORS_ORIGINS: z.string().default("http://localhost:5173,http://localhost:4173"),
|
||||
LOG_LEVEL: z.string().default("info"),
|
||||
JWT_SECRET: z.string().min(10),
|
||||
REFRESH_SECRET: z.string().min(10),
|
||||
COOKIE_SECRET: z.string().min(10),
|
||||
ACCESS_TOKEN_TTL_MIN: z.string().default("15"),
|
||||
REFRESH_TOKEN_TTL_DAYS: z.string().default("14"),
|
||||
});
|
||||
|
||||
export type Env = z.infer<typeof EnvSchema>;
|
||||
|
||||
Reference in New Issue
Block a user