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' ],
|
37 | lookupPath: 'lang',
|
38 | lookupQuerystring: 'lang',
|
39 | caches: false
|
40 | },
|
41 | };
|
42 |
|
43 | config.mailer = {
|
44 | transport: {
|
45 | host: null,
|
46 | port: 465,
|
47 | secure: true,
|
48 | auth: {
|
49 | user: null,
|
50 | pass: null
|
51 | }
|
52 | },
|
53 | defaultfrom: '',
|
54 | subaccount: null
|
55 | };
|
56 |
|
57 | config.mysql = {
|
58 | host : process.env.MYSQL_HOST || 'localhost',
|
59 | port : process.env.MYSQL_PORT || 3306,
|
60 | user : process.env.MYSQL_USERNAME || 'root',
|
61 | password : process.env.MYSQL_PASSWORD || '',
|
62 | database : process.env.MYSQL_DATABASE || 'igo',
|
63 | charset : process.env.MYSQL_CHARSET || 'utf8mb4',
|
64 | debug : false,
|
65 | connectionLimit : 5,
|
66 | debugsql : false
|
67 | };
|
68 |
|
69 | config.redis = {
|
70 | host: process.env.REDIS_HOST || 'localhost',
|
71 | port: process.env.REDIS_PORT || 6379,
|
72 | database: process.env.REDIS_DATABASE || 0
|
73 | };
|
74 |
|
75 |
|
76 | if (config.env === 'test') {
|
77 | config.mysql.database = 'test';
|
78 | config.mailer = null;
|
79 | }
|
80 |
|
81 |
|
82 | var configFiles = [
|
83 | '/app/config',
|
84 |
|
85 | ];
|
86 | configFiles.forEach(function(file) {
|
87 | try {
|
88 | require(process.cwd() + file).init(config);
|
89 | } catch (err) {
|
90 | console.error(err);
|
91 | }
|
92 | });
|
93 |
|
94 | };
|