Last active
December 28, 2015 17:22
-
-
Save jurajpelikan/233f985cff1cd626eb93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bodyParser from "body-parser"; | |
| import express from "express"; | |
| import yargs from "yargs"; | |
| const app = express(); | |
| const paths = { | |
| root: "/", | |
| descriptor: "/descriptor/", | |
| installCallback: "/install-callback/" | |
| }; | |
| const getUrl = (name) => { | |
| if (paths[name]) { | |
| return yargs.argv.ngrok + paths[name]; | |
| } | |
| return yargs.argv.ngrok; | |
| }; | |
| app.use(bodyParser.json()); | |
| app.get(paths.root, (req, res) => { | |
| res.send("<h1>Hey Ho Let's Go!</h1>"); | |
| }); | |
| app.post(paths.installCallback, (req, res) => { | |
| console.log(req.body); | |
| res.send("OK"); | |
| }); | |
| app.get(paths.descriptor, (req, res) => { | |
| res.json({ | |
| key: "hipchat-connect-example-cloudo", | |
| name: "Tutorial", | |
| description: "A simple add-on showing cool hipchat connect api features.", | |
| vendor: { | |
| name: "Juraj Pelikan", | |
| url: "https://www.cloudo.co" | |
| }, | |
| links: { | |
| self: getUrl("descriptor") | |
| }, | |
| capabilities: { | |
| hipchatApiConsumer: { | |
| scopes: [ | |
| "send_notification", | |
| "view_room" | |
| ] | |
| }, | |
| installable: { | |
| allowGlobal: true, | |
| allowRoom: true, | |
| callbackUrl: getUrl("installCallback") | |
| } | |
| } | |
| }); | |
| }); | |
| app.listen(8000, () => { | |
| console.log(`Integration descriptor url: ${getUrl("descriptor")}`); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment