diff --git a/.gitignore b/.gitignore index 22f7aa01..39f3f8f0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ node_modules # logs npm-debug.log + +# Env +.env diff --git a/bin/slackin b/bin/slackin index be0708b4..7e122fac 100755 --- a/bin/slackin +++ b/bin/slackin @@ -8,7 +8,7 @@ args .option(['p', 'port'], 'Port to listen on [$PORT or 3000]', require('hostenv').PORT || process.env.PORT || 3000) .option(['h', 'hostname'], 'Hostname to listen on [$HOSTNAME or 0.0.0.0]', require('hostenv').HOSTNAME || process.env.WEBSITE_HOSTNAME || '0.0.0.0') .option(['c', 'channels'], 'One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS]', process.env.SLACK_CHANNELS) - .option(['i', 'interval'], 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 5000]', process.env.SLACK_INTERVAL || 5000) + .option(['i', 'interval'], 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 15000]', process.env.SLACK_INTERVAL || 15000) .option(['P', 'path'], 'Path to serve slackin under', '/') .option(['s', 'silent'], 'Do not print out warns or errors') .option(['x', 'cors'], 'Enable CORS for all routes') diff --git a/lib/index.js b/lib/index.js index b4d3b6cc..09a6cc06 100644 --- a/lib/index.js +++ b/lib/index.js @@ -21,7 +21,7 @@ import log from './log' export default function slackin ({ token, - interval = 5000, // jshint ignore:line + interval = 15000, // jshint ignore:line org, gcaptcha_secret, gcaptcha_sitekey, diff --git a/lib/slack.js b/lib/slack.js index 5de4306e..cd7d0ca5 100644 --- a/lib/slack.js +++ b/lib/slack.js @@ -7,7 +7,7 @@ export default class SlackData extends EventEmitter { super() this.host = host this.token = token - this.interval = interval + this.interval = interval < 5000 ? 15000 : interval // Prevent pings of less than 5sec intervals this.ready = false this.org = {} this.users = {} diff --git a/package.json b/package.json index 7ac64270..c22a2b5c 100644 --- a/package.json +++ b/package.json @@ -69,10 +69,12 @@ "gulpfile.babel.js" ], "env": [ + "SLACK_INTERVAL", "SLACK_API_TOKEN", "SLACK_SUBDOMAIN", "GOOGLE_CAPTCHA_SECRET", "GOOGLE_CAPTCHA_SITEKEY" - ] + ], + "dotenv": ".env" } } diff --git a/readme.md b/readme.md index 9e081aaf..203fcf2a 100644 --- a/readme.md +++ b/readme.md @@ -24,6 +24,25 @@ Other platforms: - [OpenShift](https://github.com/rauchg/slackin/wiki/OpenShift) - [IBM Bluemix](https://bluemix.net/deploy?repository=https://github.com/rauchg/slackin) +### Environment Variables + +These environment variables can be used to configure the app. + +```bash +# Time in milliseconds to ping the slack api +SLACK_INTERVAL=15000 + +# Slack team id (subdomain of slack.com) +SLACK_SUBDOMAIN= + +# Slack api token of your slack app with admin permission +SLACK_API_TOKEN= + +# Google reCAPTCHA keys +GOOGLE_CAPTCHA_SITEKEY= +GOOGLE_CAPTCHA_SECRET= +``` + ### Tips Your team id is what you use to access your login page on Slack (eg: https://**{this}**.slack.com).