]> git.r.bdr.sh - rbdr/lgtm/commitdiff
Add dotenv to the configs
authorBen Beltran <redacted>
Mon, 28 Nov 2016 08:26:34 +0000 (02:26 -0600)
committerBen Beltran <redacted>
Mon, 28 Nov 2016 08:26:34 +0000 (02:26 -0600)
.gitignore
config/config.js
env.dist [new file with mode: 0644]
package.json
yarn.lock

index 5148e527a7e286a1efcc44d65a7f8241267dce9b..e0ff0f3ec0a8d973905d62903d8388220466799b 100644 (file)
@@ -35,3 +35,6 @@ jspm_packages
 
 # Optional REPL history
 .node_repl_history
 
 # Optional REPL history
 .node_repl_history
+
+# Env file
+.env
index c98a0be024c20bb91e42c84dc241d0db1a6e5c4e..ddfdb41ab91c94ff39a741fb2760afaadf8a6ad3 100644 (file)
@@ -1,11 +1,24 @@
 'use strict';
 
 const Getenv = require('getenv');
 'use strict';
 
 const Getenv = require('getenv');
+const Dotenv = require('dotenv');
+
+Dotenv.config();
 
 const internals = {};
 
 module.exports = internals.Config = {
 
 const internals = {};
 
 module.exports = internals.Config = {
-  port: Getenv.int('LGTM_PORT', 1728),
-  staticDirectory: Getenv('LGTM_STATIC_DIRECTORY', 'static'),
-  templateDirectory: Getenv('LGTM_TEMPLATE_DIRECTORY', 'templates')
+  port: Getenv.int('LGTM_PORT', 1728), // Port to listen on
+  staticDirectory: Getenv('LGTM_STATIC_DIRECTORY', 'static'), // Location of static assets
+  templateDirectory: Getenv('LGTM_TEMPLATE_DIRECTORY', 'templates'), // Location of templates
+
+  // Config to connect to mysql
+  mysql: {
+    host: Getenv('LGTM_MYSQL_HOST', 'localhost'),
+    port: Getenv('LGTM_MYSQL_PORT', 3306),
+    user: Getenv('LGTM_MYSQL_USER'),
+    password: Getenv('LGTM_MYSQL_PASSWORD'),
+    database: Getenv('LGTM_MYSQL_DATABASE'),
+    tableName: Getenv('LGTM_MYSQL_TABLE_NAME', 'lgtm') // table that will be used to fetch logs
+  }
 };
 };
diff --git a/env.dist b/env.dist
new file mode 100644 (file)
index 0000000..86849cd
--- /dev/null
+++ b/env.dist
@@ -0,0 +1,3 @@
+LGTM_MYSQL_USER=example
+LGTM_MYSQL_PASSWORD=secretExample
+LGTM_MYSQL_DATABASE=example
index 8c9a83c1870314ee6a1bb9b67293a53e7511d0e8..ffc859c08e6a5b63dd0a98afcec8b29e5b21ca17 100644 (file)
@@ -6,6 +6,7 @@
   "scripts": {
     "lint": "eslint .",
     "start": "node index",
   "scripts": {
     "lint": "eslint .",
     "start": "node index",
+    "setup_database": "node scripts/setup_database",
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "repository": {
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "repository": {
@@ -19,6 +20,7 @@
   },
   "homepage": "https://github.com/rbdr/lgtm#readme",
   "dependencies": {
   },
   "homepage": "https://github.com/rbdr/lgtm#readme",
   "dependencies": {
+    "dotenv": "^2.0.0",
     "getenv": "^0.7.0",
     "koa": "^1.2.4",
     "koa-static": "^2.0.0",
     "getenv": "^0.7.0",
     "koa": "^1.2.4",
     "koa-static": "^2.0.0",
index 013b3828e712ace1ccb46f2c0d90b1ba091f7878..a535d8127f4cd46aa670b01a449ee24a275f4f2f 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -302,6 +302,10 @@ destroy@^1.0.3:
   version "1.0.4"
   resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80"
 
   version "1.0.4"
   resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80"
 
+dotenv:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-2.0.0.tgz#bd759c357aaa70365e01c96b7b0bec08a6e0d949"
+
 ecc-jsbn@~0.1.1:
   version "0.1.1"
   resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
 ecc-jsbn@~0.1.1:
   version "0.1.1"
   resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"