Skip to content

Commit

Permalink
Merge pull request #8 from valgaze/lib_fix
Browse files Browse the repository at this point in the history
Strip superfluous features, publish fix
  • Loading branch information
valgaze authored Sep 16, 2021
2 parents ac2e557 + 01df778 commit 789ea07
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 94 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.DS_STORE
deploy/
dist/
dist/
run.sh
6 changes: 5 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
docs
docs
settings/
test/
src/
nodemon.json
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
"peerDependencies": {
"webex-node-bot-framework": "*"
},
"files": [
"dist/**"
],
"repository": {
"type": "git",
"url": "https://github.com/valgaze/speedybot.git"
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { Speedybot, SpeedybotWebhook, devLauncher, Speedytunnel, Launch } from './speedybot'
export { Speedybot, SpeedybotWebhook, Speedytunnel, Launch } from './speedybot'
export { SpeedybotConfig } from './speedybot'

// Types: framework
Expand Down
88 changes: 0 additions & 88 deletions src/speedybot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,94 +296,6 @@ export const Speedytunnel = async (app: any, port: string | number, tunneler:tun
app.post(`/${webhookRoute}`, SpeedybotWebhook(speedyConfig, handlers))
}

export type launchType = 'websockets' | 'express_tunnel'

/**
* Convenience launcher to use websockets or tunneling (via nGrok)
*
* > Add dependencies
* ```sh
* npm i speedyhelper express body-parser
* ```
*
* ## Websockets sample
```sh
const { devLauncher } = require('speedybot')
const config = {
token: `aaa-bbb-ccc-ddd`
}
const handlers = [
{
keyword: ['hello', 'hey', 'yo', 'watsup', 'hola'],
handler(bot, trigger) {
const reply = 'Heya how\'s it going ' + trigger.person.displayName + '?'
bot.say(reply)
},
helpText: 'A handler that greets the user'
}
]
devLauncher('websockets', config, handlers)
```
*
* ```
*
* ## Express + tunnel sample
```js
const { devLauncher } = require('speedybot')
const { nGrokTunnel } = require('speedyhelper')
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
const port = process.env.PORT || 8000
app.use(bodyParser.json());
app.post('/ping', (req, res) => res.send('pong!'))
const config = {
token: 'aaa-bbb-ccc-ddd'
}
const handlers = [
{
keyword: ['hello', 'hey', 'yo', 'watsup', 'hola'],
handler(bot, trigger) {
const reply = `Heya how's it going ${trigger.person.displayName}?`
bot.say(reply)
},
helpText: `A handler that greets the user`
}
]
// Launch tunnel service (via nGroK) for webhooks
devLauncher('express_tunnel', config, handlers, app, nGrokTunnel, port)
app.listen(port, () => {
console.log(`Listening + tunneled on port ${port}`)
})
```
*
* @param type
* @param config
* @param handlerList
* @param expressApp
* @param tunneler
* @param port
* @returns
*/
export const devLauncher = async (type:launchType, config: SpeedybotConfig, handlerList: BotHandler[], expressApp?:any, tunneler?:tunnlerFunc, port?: number | string) => {
if (type === 'websockets' || !type) {
// launch with websockets
const speedybot = new Speedybot(config);
speedybot.loadHandlers(handlerList)
const frameworkRef = await speedybot.start()
return frameworkRef
} else if (type === 'express_tunnel') {
Speedytunnel(expressApp, port as number, tunneler as tunnlerFunc, config, handlerList)
return true
}
}

/**
*
* @param config: Speedybot Config
Expand Down

0 comments on commit 789ea07

Please sign in to comment.