1- import { config } from "dotenv" ;
2- import { resolve } from "path" ;
3-
4- // Load environment variables from root directory
5- config ( { path : resolve ( process . cwd ( ) , "../../.env" ) } ) ;
6-
71import express from "express" ;
82import cors from "cors" ;
93import pinRoutes from "@routes/pinRoutes.js" ;
@@ -21,21 +15,21 @@ const app = express();
2115// Configure CORS - simplified for development
2216const corsOptions = env . isDevelopment ( )
2317 ? {
24- // In development, allow all origins for easier debugging
25- origin : true ,
26- credentials : true ,
27- methods : [ "GET" , "POST" , "PUT" , "DELETE" , "OPTIONS" ] ,
28- allowedHeaders : [ "Content-Type" , "Authorization" , "X-User-PIN" ] ,
29- optionsSuccessStatus : 200 ,
30- }
18+ // In development, allow all origins for easier debugging
19+ origin : true ,
20+ credentials : true ,
21+ methods : [ "GET" , "POST" , "PUT" , "DELETE" , "OPTIONS" ] ,
22+ allowedHeaders : [ "Content-Type" , "Authorization" , "X-User-PIN" ] ,
23+ optionsSuccessStatus : 200 ,
24+ }
3125 : {
32- // In production, use strict origin checking
33- origin : env . CORS_ORIGINS ,
34- credentials : true ,
35- methods : [ "GET" , "POST" , "PUT" , "DELETE" , "OPTIONS" ] ,
36- allowedHeaders : [ "Content-Type" , "Authorization" , "X-User-PIN" ] ,
37- optionsSuccessStatus : 200 ,
38- } ;
26+ // In production, use strict origin checking
27+ origin : env . CORS_ORIGINS ,
28+ credentials : true ,
29+ methods : [ "GET" , "POST" , "PUT" , "DELETE" , "OPTIONS" ] ,
30+ allowedHeaders : [ "Content-Type" , "Authorization" , "X-User-PIN" ] ,
31+ optionsSuccessStatus : 200 ,
32+ } ;
3933
4034app . use ( cors ( corsOptions ) ) ;
4135
@@ -69,14 +63,14 @@ initializeDatabase()
6963 console . log (
7064 `🚀 Server running at http://${ env . SERVER_HOST } :${ env . SERVER_PORT } `
7165 ) ;
72- console . log ( `📊 Environment: ${ env . NODE_ENV } ` ) ;
73- console . log ( `🗄️ Database: ${ env . DATABASE_PATH } ` ) ;
74- console . log ( `🎭 Demo Mode: ${ env . DEMO_MODE ? "Enabled" : "Disabled" } ` ) ;
66+ console . log ( `Environment: ${ env . ENVIRONMENT } ` ) ;
67+ console . log ( `Database: ${ env . DATABASE_PATH } ` ) ;
68+ console . log ( `Demo Mode: ${ env . DEMO_MODE ? "Enabled" : "Disabled" } ` ) ;
7569 console . log (
76- `🌐 CORS: ${ env . isDevelopment ( ) ? "Permissive (Development)" : "Strict (Production)" } `
70+ `CORS: ${ env . isDevelopment ( ) ? "Permissive (Development)" : "Strict (Production)" } `
7771 ) ;
7872 if ( ! env . isDevelopment ( ) ) {
79- console . log ( `📋 Allowed origins: ${ env . CORS_ORIGINS . join ( ", " ) } ` ) ;
73+ console . log ( `Allowed origins: ${ env . CORS_ORIGINS . join ( ", " ) } ` ) ;
8074 }
8175 console . log ( "─" . repeat ( 75 ) ) ;
8276 } ) ;
0 commit comments