Skip to content

Commit 0b5e15b

Browse files
authored
Create config.js
1 parent 1dab083 commit 0b5e15b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/config/config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Load environment variables from .env file
2+
require('dotenv').config();
3+
4+
// Configuration object
5+
const config = {
6+
authyApiKey: process.env.AUTHY_API_KEY, // Authy API key for MFA
7+
port: process.env.PORT || 3000, // Server port, defaults to 3000
8+
dbConnectionString: process.env.DB_CONNECTION_STRING, // Database connection string
9+
logLevel: process.env.LOG_LEVEL || 'info', // Logging level, defaults to 'info'
10+
};
11+
12+
// Validate required configurations
13+
const validateConfig = () => {
14+
if (!config.authyApiKey) {
15+
throw new Error('Missing Authy API key. Please set AUTHY_API_KEY in your .env file.');
16+
}
17+
if (!config.dbConnectionString) {
18+
throw new Error('Missing database connection string. Please set DB_CONNECTION_STRING in your .env file.');
19+
}
20+
};
21+
22+
// Call the validation function
23+
validateConfig();
24+
25+
module.exports = config;

0 commit comments

Comments
 (0)