Skip to content

Commit

Permalink
functions/slack: config.json -> env vars (#1751)
Browse files Browse the repository at this point in the history
**Do not merge** until @labtopia updates the docs accordingly.
  • Loading branch information
Ace Nassri authored Apr 28, 2020
1 parent fab87f8 commit da03d9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions functions/slack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
'use strict';

// [START functions_slack_setup]
const config = require('./config.json');
const {google} = require('googleapis');
const {verifyRequestSignature} = require('@slack/events-api');

Expand Down Expand Up @@ -94,7 +93,7 @@ const formatSlackMessage = (query, response) => {
*/
const verifyWebhook = (req) => {
const signature = {
signingSecret: config.SLACK_SECRET,
signingSecret: process.env.SLACK_SECRET,
requestSignature: req.headers['x-slack-signature'],
requestTimestamp: req.headers['x-slack-request-timestamp'],
body: req.rawBody,
Expand All @@ -118,7 +117,7 @@ const makeSearchRequest = (query) => {
return new Promise((resolve, reject) => {
kgsearch.entities.search(
{
auth: config.KG_API_KEY,
auth: process.env.KG_API_KEY,
query: query,
limit: 1,
},
Expand Down
2 changes: 1 addition & 1 deletion functions/slack/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const getSample = () => {
return {
program: proxyquire('../', {
googleapis: {google: googleapis},
'./config.json': config,
process: { env: config },
'@slack/events-api': eventsApi,
}),
mocks: {
Expand Down

0 comments on commit da03d9b

Please sign in to comment.