From 5295f57d1fbb1e6ba68b766e058ee6a46a3e9895 Mon Sep 17 00:00:00 2001 From: German Attanasio Date: Wed, 6 Nov 2019 16:03:59 -0500 Subject: [PATCH 1/2] fix: update travis --- app.js | 54 +++++++++++++++++++++++++++++----------------------- package.json | 2 +- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/app.js b/app.js index b5a76a54..5df1e466 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,5 @@ /** - * + * * Copyright 2015 IBM Corp. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,26 +33,29 @@ app.use(bodyParser.json()); var assistant = new AssistantV2({ version: '2019-02-28', authenticator: new IamAuthenticator({ - apikey: process.env.ASSISTANT_IAM_APIKEY + apikey: process.env.ASSISTANT_IAM_APIKEY, }), - url: process.env.ASSISTANT_IAM_URL, + url: process.env.ASSISTANT_URL, }); - // Endpoint to be call from the client side -app.post('/api/message', function (req, res) { +app.post('/api/message', function(req, res) { let assistantId = process.env.ASSISTANT_ID || ''; if (!assistantId || assistantId === '') { return res.json({ - 'output': { - 'text': 'The app has not been configured with a ASSISTANT_ID environment variable. Please refer to the ' + 'README documentation on how to set this variable.
' + 'Once a workspace has been defined the intents may be imported from ' + 'here in order to get a working application.' - } + output: { + text: + 'The app has not been configured with a ASSISTANT_ID environment variable. Please refer to the ' + + 'README documentation on how to set this variable.
' + + 'Once a workspace has been defined the intents may be imported from ' + + 'here in order to get a working application.', + }, }); } var textIn = ''; - if(req.body.input) { + if (req.body.input) { textIn = req.body.input.text; } @@ -60,15 +63,15 @@ app.post('/api/message', function (req, res) { assistantId: assistantId, sessionId: req.body.session_id, input: { - message_type : 'text', - text : textIn - } + message_type: 'text', + text: textIn, + }, }; // Send the input to the assistant service - assistant.message(payload, function (err, data) { + assistant.message(payload, function(err, data) { if (err) { - const status = (err.code !== undefined && err.code > 0)? err.code : 500; + const status = err.code !== undefined && err.code > 0 ? err.code : 500; return res.status(status).json(err); } @@ -76,16 +79,19 @@ app.post('/api/message', function (req, res) { }); }); -app.get('/api/session', function (req, res) { - assistant.createSession({ - assistantId: process.env.ASSISTANT_ID || '{assistant_id}', - }, function (error, response) { - if (error) { - return res.send(error); - } else { - return res.send(response); +app.get('/api/session', function(req, res) { + assistant.createSession( + { + assistantId: process.env.ASSISTANT_ID || '{assistant_id}', + }, + function(error, response) { + if (error) { + return res.send(error); + } else { + return res.send(response); + } } - }); + ); }); -module.exports = app; \ No newline at end of file +module.exports = app; diff --git a/package.json b/package.json index 76d74cd0..20ab1f03 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "access": "public" }, "engines": { - "node": ">=8.15.0" + "node": ">=12" }, "engineStrict": true, "devDependencies": { From 24195106bff1715b172b3c9090f9a17071495242 Mon Sep 17 00:00:00 2001 From: German Attanasio Date: Wed, 6 Nov 2019 16:04:22 -0500 Subject: [PATCH 2/2] fix: update travis --- .travis.yml | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61c93ee9..c631fde6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,27 @@ language: node_js dist: trusty sudo: required -node_js: 8 +node_js: 12 script: -- npm run test + - npm run test cache: directories: - - node_modules + - node_modules env: global: - - BX_APP=watson-assistant-simple - - BX_API=https://api.ng.bluemix.net - - BX_ORGANIZATION=WatsonPlatformServices - - BX_SPACE=demos + - BX_APP=watson-assistant-simple + - BX_API=https://api.ng.bluemix.net + - BX_ORGANIZATION=WatsonPlatformServices + - BX_SPACE=demos before_deploy: npm install -g bx-blue-green deploy: -- provider: script - skip_cleanup: true - script: - - bx-blue-green-travis - on: - branch: master - repo: watson-developer-cloud/assistant-simple -- provider: script - skip_cleanup: true - script: npx semantic-release - on: - node: 8 - + - provider: script + skip_cleanup: true + script: bx-blue-green-travis + on: + branch: master + repo: watson-developer-cloud/assistant-simple + - provider: script + skip_cleanup: true + script: npx semantic-release