0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 12:02:48 +00:00

[NFC] Outline config creation into a separate module

This is done in order to have config creation rules
unified in one place to avoid modifying them multiple times
if they change.

We already had 3 duplicated pieces of code initializing the
config and there will be more config uses in future tests.

This resolves #1960
This commit is contained in:
Alexey Sachkov
2022-01-21 23:11:44 +03:00
parent 179d5e6312
commit 588bcebc87
4 changed files with 8 additions and 15 deletions

View File

@@ -1,11 +1,7 @@
const DB = require('./server/db.js');
const server = require('./server/app.js');
const config = require('nconf')
.argv()
.env({ lowerCase: true })
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
.file('defaults', { file: 'config/default.json' });
const config = require('./server/config.js');
DB.connect(config).then(()=>{
// Ensure that we have successfully connected to the database

5
server/config.js Normal file
View File

@@ -0,0 +1,5 @@
module.exports = require('nconf')
.argv()
.env({ lowerCase: true })
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
.file('defaults', { file: 'config/default.json' });

View File

@@ -3,11 +3,7 @@ const _ = require('lodash');
const { google } = require('googleapis');
const { nanoid } = require('nanoid');
const token = require('./token.js');
const config = require('nconf')
.argv()
.env({ lowerCase: true }) // Load environment variables
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
.file('defaults', { file: 'config/default.json' });
const config = require('./config.js');
//let oAuth2Client;

View File

@@ -1,11 +1,7 @@
const jwt = require('jwt-simple');
// Load configuration values
const config = require('nconf')
.argv()
.env({ lowerCase: true }) // Load environment variables
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
.file('defaults', { file: 'config/default.json' });
const config = require('./config.js');
// Generate an Access Token for the given User ID
const generateAccessToken = (account)=>{