2022-04-08 10:37:27 -07:00
|
|
|
/* eslint-disable @typescript-eslint/unbound-method */
|
2021-08-29 11:58:11 -07:00
|
|
|
/* eslint-disable no-console */
|
2022-04-08 14:32:08 -07:00
|
|
|
import convict from 'convict';
|
|
|
|
import dotenv from 'dotenv';
|
2022-04-08 10:37:27 -07:00
|
|
|
import { schema } from './schema';
|
2019-07-21 10:47:41 -07:00
|
|
|
|
|
|
|
dotenv.config();
|
|
|
|
|
2022-04-08 10:37:27 -07:00
|
|
|
const config = convict(schema);
|
2019-07-21 10:47:41 -07:00
|
|
|
|
2022-04-08 10:37:27 -07:00
|
|
|
config.getEnv = config.get;
|
2019-07-21 10:47:41 -07:00
|
|
|
|
2020-03-27 04:30:42 -07:00
|
|
|
// Overwrite default configuration with settings which got defined in
|
|
|
|
// optional configuration files
|
|
|
|
if (process.env.N8N_CONFIG_FILES !== undefined) {
|
2020-03-29 03:46:55 -07:00
|
|
|
const configFiles = process.env.N8N_CONFIG_FILES.split(',');
|
2022-06-30 06:05:23 -07:00
|
|
|
if (process.env.NODE_ENV !== 'test') {
|
|
|
|
console.log(`\nLoading configuration overwrites from:\n - ${configFiles.join('\n - ')}\n`);
|
|
|
|
}
|
2020-03-27 04:30:42 -07:00
|
|
|
|
2020-03-29 03:46:55 -07:00
|
|
|
config.loadFile(configFiles);
|
2020-03-27 04:30:42 -07:00
|
|
|
}
|
|
|
|
|
2019-07-21 10:47:41 -07:00
|
|
|
config.validate({
|
|
|
|
allowed: 'strict',
|
|
|
|
});
|
|
|
|
|
2021-06-23 02:20:07 -07:00
|
|
|
export = config;
|