Change how listening port is defined
This commit is contained in:
parent
56b99d2758
commit
93ce360551
|
@ -1,11 +1,17 @@
|
||||||
slack-command-server
|
slack-command-server
|
||||||
====================
|
====================
|
||||||
Slack command server is a simple way to build a server that responds to slack slash commands.
|
Slack command server is a simple way to build a server that responds to slack slash commands.
|
||||||
|
Getting Started
|
||||||
|
===============
|
||||||
|
1. Clone this repository
|
||||||
|
2. Configure according to the `Configuration` section
|
||||||
|
3.
|
||||||
Configuration
|
Configuration
|
||||||
=============
|
=============
|
||||||
Configuring the server is simple, you can use any plugin compatible with [slack-command-router](https://github.com/terribly-lazy/slack-command-router), custom or otherwise.
|
Configuring the server is simple, you can use any plugin compatible with [slack-command-router](https://github.com/terribly-lazy/slack-command-router), custom or otherwise.
|
||||||
|
|
||||||
|
You must define what port for the app to listen on by defining `port: 80`
|
||||||
|
|
||||||
To use pre-written plugins write your configuration thusly:
|
To use pre-written plugins write your configuration thusly:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|
17
app.js
17
app.js
|
@ -1,10 +1,19 @@
|
||||||
var connect = require('connect'),
|
var connect = require('connect'),
|
||||||
SlackIncoming = require('slack-command-router'),
|
SlackIncoming = require('slack-command-router'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
fs = require('fs');
|
fs = require('fs'),
|
||||||
|
_ = require('lodash');
|
||||||
|
|
||||||
var config = JSON.parse(fs.readFileSync("config.json")),
|
var config = JSON.parse(fs.readFileSync("config.json"));
|
||||||
slack = new SlackIncoming();
|
|
||||||
|
var requiredSetup = ["port"];
|
||||||
|
if (_.intersection(_.keys(config), requiredSetup).length !== requiredSetup.length) {
|
||||||
|
throw {
|
||||||
|
message: "Missing required configuration parameters"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var slack = new SlackIncoming();
|
||||||
|
|
||||||
var pluginsToInstall = config.plugins || [],
|
var pluginsToInstall = config.plugins || [],
|
||||||
pluginsToLoad = config["local-plugins"] || [];
|
pluginsToLoad = config["local-plugins"] || [];
|
||||||
|
@ -56,7 +65,7 @@ function startApp() {
|
||||||
res.writeHead(400);
|
res.writeHead(400);
|
||||||
res.end("Unable to handle request");
|
res.end("Unable to handle request");
|
||||||
});
|
});
|
||||||
app.listen(2354);
|
app.listen(config.port);
|
||||||
}
|
}
|
||||||
|
|
||||||
installPlugins(initCallback(function() {
|
installPlugins(initCallback(function() {
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"slack-roll-command"
|
"slack-roll-command"
|
||||||
],
|
],
|
||||||
"local-plugins": []
|
"local-plugins": [],
|
||||||
|
"port": 80
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "slack-command-server",
|
"name": "slack-command-server",
|
||||||
"version": "0.0.0",
|
"version": "0.0.1",
|
||||||
"description": "A slack slash command hander framework",
|
"description": "A slack slash command hander framework",
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"connect": "~3.1.0",
|
"connect": "~3.1.0",
|
||||||
|
"lodash": "^2.4.1",
|
||||||
"npm": "^1.4.23",
|
"npm": "^1.4.23",
|
||||||
"require-directory": "~2.0.0",
|
"require-directory": "~2.0.0",
|
||||||
"slack-command-router": "0.0.0"
|
"slack-command-router": "0.0.0"
|
||||||
|
|
Loading…
Reference in a new issue