File tree Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,6 @@ DB_HOST=localhost
44DB_USER = root
55DB_PASS =
66DB_NAME = dbname
7+
8+ JWT_SECRET = secret
9+ JWT_EXPIRES_IN = 90d
Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ import { config } from "dotenv";
22
33config ( ) ;
44
5- export default {
5+ const dbConfig = {
66 HOST : process . env . DB_HOST ,
77 USER : process . env . DB_USER ,
88 PASSWORD : process . env . DB_PASS ,
99 DATABASE : process . env . DB_NAME ,
10- } ;
10+ } ;
11+
12+ export default dbConfig ;
Original file line number Diff line number Diff line change @@ -2,4 +2,10 @@ import { config } from 'dotenv';
22
33config ( ) ;
44
5- export const port = process . env . PORT ;
5+ const serverConfig = {
6+ PORT : process . env . PORT ,
7+ JWT_SECRET : process . env . SECRET ,
8+ JWT_EXPIRES_IN : process . env . EXPIRES_IN
9+ } ;
10+
11+ export default serverConfig ;
Original file line number Diff line number Diff line change 11import app from './app' ;
2- import { port } from './config/server.config' ;
3- import db from './services/db' ;
2+ import serverConfig from './config/server.config' ;
3+ import db from './services/db.service' ;
4+
5+ const { PORT } = serverConfig ;
46
57const initApp = async ( ) => {
68 try {
@@ -9,8 +11,8 @@ const initApp = async () => {
911 await db . sync ( { force : true } ) ;
1012 console . log ( "Database connection has been established successfully." ) ;
1113
12- app . listen ( port || 3000 , ( ) => {
13- console . log ( `Server running at http://localhost:${ port } ` ) ;
14+ app . listen ( PORT || 3000 , ( ) => {
15+ console . log ( `Server running at http://localhost:${ PORT } ` ) ;
1416 } ) ;
1517 } catch ( error ) {
1618 console . error ( "Unable to connect to the database:" , error ) ;
You can’t perform that action at this time.
0 commit comments