Skip to content

Commit

Permalink
Add dotenv to obscure API key
Browse files Browse the repository at this point in the history
  • Loading branch information
Leta Keane committed May 25, 2017
1 parent 9a35cd0 commit c5c278b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
.env
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"license": "ISC",
"dependencies": {
"body-parser": "^1.16.0",
"dotenv": "^4.0.0",
"express": "^4.14.0",
"express-cors": "0.0.3",
"nodemon": "^1.11.0",
Expand Down
11 changes: 6 additions & 5 deletions src/controller.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
const request = require('request')
const API_KEY = require('./key')
const BASE_URL = `https://westus.api.cognitive.microsoft.com/emotion/v1.0/recognize`
const IMAGE_URL = 'localhost:300/image'
require('dotenv').load()
const API_KEY = process.env.EMOTION_API_KEY
const API_URL = `https://westus.api.cognitive.microsoft.com/emotion/v1.0/recognize`
const APP_BASE_URL = 'localhost:3000'


function getEmotionAnalysis(req, res) {
request({
url: BASE_URL,
url: API_URL,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': API_KEY
},
body: JSON.stringify({url: IMAGE_URL})
body: JSON.stringify({url: /*IMAGE URL GOES HERE SOMEHOW*/})
},
function (error, response, body) {
if (!error && response.statusCode == 200) {
Expand Down

0 comments on commit c5c278b

Please sign in to comment.