From: Ben Beltran Date: Mon, 28 Nov 2016 08:26:34 +0000 (-0600) Subject: Add dotenv to the configs X-Git-Url: https://git.r.bdr.sh/rbdr/lgtm/commitdiff_plain/d6d8813ef55bb1297089c9dbb87a9ab86e6c5ba2 Add dotenv to the configs --- diff --git a/.gitignore b/.gitignore index 5148e52..e0ff0f3 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ jspm_packages # Optional REPL history .node_repl_history + +# Env file +.env diff --git a/config/config.js b/config/config.js index c98a0be..ddfdb41 100644 --- a/config/config.js +++ b/config/config.js @@ -1,11 +1,24 @@ 'use strict'; const Getenv = require('getenv'); +const Dotenv = require('dotenv'); + +Dotenv.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 index 0000000..86849cd --- /dev/null +++ b/env.dist @@ -0,0 +1,3 @@ +LGTM_MYSQL_USER=example +LGTM_MYSQL_PASSWORD=secretExample +LGTM_MYSQL_DATABASE=example diff --git a/package.json b/package.json index 8c9a83c..ffc859c 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "lint": "eslint .", "start": "node index", + "setup_database": "node scripts/setup_database", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -19,6 +20,7 @@ }, "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", diff --git a/yarn.lock b/yarn.lock index 013b382..a535d81 100644 --- 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" +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"