1 |
|
2 | require('dotenv').config({silent: true});
|
3 |
|
4 |
|
5 |
|
6 | const config = {};
|
7 | module.exports = config;
|
8 |
|
9 |
|
10 | module.exports.init = function() {
|
11 |
|
12 | if (config._loaded) {
|
13 | return;
|
14 | }
|
15 |
|
16 | config._loaded = true;
|
17 | config.env = process.env.NODE_ENV || 'dev';
|
18 | config.httpport = process.env.HTTP_PORT || 3000;
|
19 |
|
20 | config.bodyParser = { limit: '100kb' };
|
21 | config.signedCookiesSecret = 'abcdefghijklmnopqrstuvwxyz';
|
22 | config.cookieSessionConfig = {
|
23 | name: 'app',
|
24 | keys: [ 'aaaaaaaaaaa' ],
|
25 | maxAge: 24 * 60 * 60 * 1000
|
26 | };
|
27 |
|
28 | config.i18n = {
|
29 | whitelist: [ 'en', 'fr' ],
|
30 | preload: [ 'en', 'fr' ],
|
31 | fallbackLng: 'en',
|
32 | backend: {
|
33 | loadPath: 'locales/{{lng}}/{{ns}}.json',
|
34 | },
|
35 | detection: {
|
36 | order: [ 'querystring', 'path', 'cookie' ],
|
37 | lookupPath: 'lang',
|
38 | lookupQuerystring: 'lang',
|
39 | lookupCookie: 'lang',
|
40 | caches: [ 'cookie' ]
|
41 | },
|
42 | };
|
43 |
|
44 | config.mailer = {
|
45 | transport: {
|
46 | host: null,
|
47 | port: 465,
|
48 | secure: true,
|
49 | auth: {
|
50 | user: null,
|
51 | pass: null
|
52 | }
|
53 | },
|
54 | defaultfrom: '',
|
55 | subaccount: null
|
56 | };
|
57 |
|
58 | config.mysql = {
|
59 | host : process.env.MYSQL_HOST || 'localhost',
|
60 | port : process.env.MYSQL_PORT || 3306,
|
61 | user : process.env.MYSQL_USERNAME || 'root',
|
62 | password : process.env.MYSQL_PASSWORD || '',
|
63 | database : process.env.MYSQL_DATABASE || 'igo',
|
64 | charset : process.env.MYSQL_CHARSET || 'utf8mb4',
|
65 | debug : false,
|
66 | connectionLimit : 5,
|
67 | debugsql : false
|
68 | };
|
69 |
|
70 | config.redis = {
|
71 | host: process.env.REDIS_HOST || 'localhost',
|
72 | port: process.env.REDIS_PORT || 6379,
|
73 | database: process.env.REDIS_DATABASE || 0
|
74 | };
|
75 |
|
76 |
|
77 | if (config.env === 'test') {
|
78 | config.mysql.database = 'test';
|
79 | config.mailer = null;
|
80 | }
|
81 |
|
82 |
|
83 | var configFiles = [
|
84 | '/app/config',
|
85 |
|
86 | ];
|
87 | configFiles.forEach(function(file) {
|
88 | try {
|
89 | require(process.cwd() + file).init(config);
|
90 | } catch (err) {
|
91 | console.error(err);
|
92 | }
|
93 | });
|
94 |
|
95 | };
|