Skip to content

Commit d9fa7a3

Browse files
Merge pull request #250 from watson-developer-cloud/depups
Fix travis and update dependencies
2 parents 962d7ff + 2419510 commit d9fa7a3

File tree

3 files changed

+47
-45
lines changed

3 files changed

+47
-45
lines changed

.travis.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
language: node_js
22
dist: trusty
33
sudo: required
4-
node_js: 8
4+
node_js: 12
55
script:
6-
- npm run test
6+
- npm run test
77

88
cache:
99
directories:
10-
- node_modules
10+
- node_modules
1111
env:
1212
global:
13-
- BX_APP=watson-assistant-simple
14-
- BX_API=https://api.ng.bluemix.net
15-
- BX_ORGANIZATION=WatsonPlatformServices
16-
- BX_SPACE=demos
13+
- BX_APP=watson-assistant-simple
14+
- BX_API=https://api.ng.bluemix.net
15+
- BX_ORGANIZATION=WatsonPlatformServices
16+
- BX_SPACE=demos
1717
before_deploy: npm install -g bx-blue-green
1818
deploy:
19-
- provider: script
20-
skip_cleanup: true
21-
script:
22-
- bx-blue-green-travis
23-
on:
24-
branch: master
25-
repo: watson-developer-cloud/assistant-simple
26-
- provider: script
27-
skip_cleanup: true
28-
script: npx semantic-release
29-
on:
30-
node: 8
31-
19+
- provider: script
20+
skip_cleanup: true
21+
script: bx-blue-green-travis
22+
on:
23+
branch: master
24+
repo: watson-developer-cloud/assistant-simple
25+
- provider: script
26+
skip_cleanup: true
27+
script: npx semantic-release

app.js

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
*
2+
*
33
* Copyright 2015 IBM Corp. All Rights Reserved.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,59 +33,65 @@ app.use(bodyParser.json());
3333
var assistant = new AssistantV2({
3434
version: '2019-02-28',
3535
authenticator: new IamAuthenticator({
36-
apikey: process.env.ASSISTANT_IAM_APIKEY
36+
apikey: process.env.ASSISTANT_IAM_APIKEY,
3737
}),
38-
url: process.env.ASSISTANT_IAM_URL,
38+
url: process.env.ASSISTANT_URL,
3939
});
4040

41-
4241
// Endpoint to be call from the client side
43-
app.post('/api/message', function (req, res) {
42+
app.post('/api/message', function(req, res) {
4443
let assistantId = process.env.ASSISTANT_ID || '<assistant-id>';
4544
if (!assistantId || assistantId === '<assistant-id>') {
4645
return res.json({
47-
'output': {
48-
'text': 'The app has not been configured with a <b>ASSISTANT_ID</b> environment variable. Please refer to the ' + '<a href="https://github.com/watson-developer-cloud/assistant-simple">README</a> documentation on how to set this variable. <br>' + 'Once a workspace has been defined the intents may be imported from ' + '<a href="https://github.com/watson-developer-cloud/assistant-simple/blob/master/training/car_workspace.json">here</a> in order to get a working application.'
49-
}
46+
output: {
47+
text:
48+
'The app has not been configured with a <b>ASSISTANT_ID</b> environment variable. Please refer to the ' +
49+
'<a href="https://github.com/watson-developer-cloud/assistant-simple">README</a> documentation on how to set this variable. <br>' +
50+
'Once a workspace has been defined the intents may be imported from ' +
51+
'<a href="https://github.com/watson-developer-cloud/assistant-simple/blob/master/training/car_workspace.json">here</a> in order to get a working application.',
52+
},
5053
});
5154
}
5255

5356
var textIn = '';
5457

55-
if(req.body.input) {
58+
if (req.body.input) {
5659
textIn = req.body.input.text;
5760
}
5861

5962
var payload = {
6063
assistantId: assistantId,
6164
sessionId: req.body.session_id,
6265
input: {
63-
message_type : 'text',
64-
text : textIn
65-
}
66+
message_type: 'text',
67+
text: textIn,
68+
},
6669
};
6770

6871
// Send the input to the assistant service
69-
assistant.message(payload, function (err, data) {
72+
assistant.message(payload, function(err, data) {
7073
if (err) {
71-
const status = (err.code !== undefined && err.code > 0)? err.code : 500;
74+
const status = err.code !== undefined && err.code > 0 ? err.code : 500;
7275
return res.status(status).json(err);
7376
}
7477

7578
return res.json(data);
7679
});
7780
});
7881

79-
app.get('/api/session', function (req, res) {
80-
assistant.createSession({
81-
assistantId: process.env.ASSISTANT_ID || '{assistant_id}',
82-
}, function (error, response) {
83-
if (error) {
84-
return res.send(error);
85-
} else {
86-
return res.send(response);
82+
app.get('/api/session', function(req, res) {
83+
assistant.createSession(
84+
{
85+
assistantId: process.env.ASSISTANT_ID || '{assistant_id}',
86+
},
87+
function(error, response) {
88+
if (error) {
89+
return res.send(error);
90+
} else {
91+
return res.send(response);
92+
}
8793
}
88-
});
94+
);
8995
});
9096

91-
module.exports = app;
97+
module.exports = app;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"access": "public"
3030
},
3131
"engines": {
32-
"node": ">=8.15.0"
32+
"node": ">=12"
3333
},
3434
"engineStrict": true,
3535
"devDependencies": {

0 commit comments

Comments
 (0)