Skip to content

Commit

Permalink
feat: add clapback functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Liendo committed Jun 26, 2018
1 parent 9edbb4c commit 6bf68d5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
require('dotenv').config()
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const slackv1Router = require('./routes/slackv1-router')
const {PORT} = process.env

app.use(bodyParser.urlencoded({extended:false}))
app.use('/slack/v1',slackv1Router)

app.listen(PORT, () => console.log(`server running on port: ${PORT}`))
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"start:dev": "nodemon index.js"
},
"dependencies": {
"body-parser": "^1.18.3",
"dotenv": "^6.0.0",
"express": "^4.16.3"
},
Expand Down
13 changes: 11 additions & 2 deletions routes/slackv1-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ const express = require('express')
const slackv1Router = express.Router()

slackv1Router.post('/sassy', (req,res) => {
res.send('hello')
})
const {text} = req.body
// 1. trim outside whitespace
// 2. capitalize
// 3. split by internal whitespace
// 4. append 👏🏾 to the end of each work
// 5. join back together

const clapbackText = text.trim().toUpperCase().split(' ').map(word => `${word} :clap::skin-tone-5:`).join(' ')
console.log(clapbackText)
res.status(200).send(clapbackText)
})

module.exports = slackv1Router
32 changes: 30 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ body-parser@1.18.2:
raw-body "2.3.2"
type-is "~1.6.15"

body-parser@^1.18.3:
version "1.18.3"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.3.tgz#5b292198ffdd553b3a0f20ded0592b956955c8b4"
dependencies:
bytes "3.0.0"
content-type "~1.0.4"
debug "2.6.9"
depd "~1.1.2"
http-errors "~1.6.3"
iconv-lite "0.4.23"
on-finished "~2.3.0"
qs "6.5.2"
raw-body "2.3.3"
type-is "~1.6.16"

boxen@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b"
Expand Down Expand Up @@ -675,7 +690,7 @@ http-errors@1.6.2:
setprototypeof "1.0.3"
statuses ">= 1.3.1 < 2"

http-errors@~1.6.2:
http-errors@1.6.3, http-errors@~1.6.2, http-errors@~1.6.3:
version "1.6.3"
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d"
dependencies:
Expand All @@ -688,7 +703,7 @@ iconv-lite@0.4.19:
version "0.4.19"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"

iconv-lite@^0.4.4:
iconv-lite@0.4.23, iconv-lite@^0.4.4:
version "0.4.23"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63"
dependencies:
Expand Down Expand Up @@ -1302,6 +1317,10 @@ qs@6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"

qs@6.5.2:
version "6.5.2"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"

range-parser@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e"
Expand All @@ -1315,6 +1334,15 @@ raw-body@2.3.2:
iconv-lite "0.4.19"
unpipe "1.0.0"

raw-body@2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.3.tgz#1b324ece6b5706e153855bc1148c65bb7f6ea0c3"
dependencies:
bytes "3.0.0"
http-errors "1.6.3"
iconv-lite "0.4.23"
unpipe "1.0.0"

rc@^1.0.1, rc@^1.1.6, rc@^1.2.7:
version "1.2.8"
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
Expand Down

0 comments on commit 6bf68d5

Please sign in to comment.