Browse Source

added support for .env file for local testing
- updated .gitignore

camalot 7 years ago
parent
commit
345a399f07
3 changed files with 43 additions and 1 deletions
  1. 31 1
      .gitignore
  2. 11 0
      bin/www
  3. 1 0
      package.json

+ 31 - 1
.gitignore

@@ -1 +1,31 @@
-node_modules/
+# Logs
+logs
+*.log
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
+node_modules
+
+
+.env
+.env.*

+ 11 - 0
bin/www

@@ -4,6 +4,17 @@
  * Module dependencies.
  */
 
+var path = require('path');
+var fs = require('fs');
+var envFile = path.join(__dirname, '../.env');
+try {
+  fs.accessSync(envFile, fs.F_OK);
+  console.log("loading .env file");
+  require('dotenv').config({path: envFile});
+} catch (e) {
+  // no env file
+}
+
 var app = require('../app');
 var debug = require('debug')('slack-invite-automation:server');
 var http = require('http');

+ 1 - 0
package.json

@@ -9,6 +9,7 @@
     "body-parser": "^1.14.0",
     "cookie-parser": "^1.4.0",
     "debug": "^2.2.0",
+    "dotenv": "^2.0.0",
     "express": "^4.13.0",
     "i18n": "^0.7.0",
     "jade": "^1.11.0",