From 08c038d01efa70d603faa5e4abc2793c9d2943a1 Mon Sep 17 00:00:00 2001 From: mountaindude Date: Thu, 5 Jan 2017 23:35:10 +0100 Subject: [PATCH] Added id of created app in API response --- README.md | 30 +++++++++++++++--------------- index.js | 10 ++++++---- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 2fe9fb9..b4db049 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Standard curl is used below, the assumption is that the command is executed on t curl -X GET "http://localhost:8000/getTemplateList" ``` -Returns a HTTP 200 response, with a json structure such as +Returns a HTTP 200 response, with a JSON structure such as ```json [{ @@ -91,13 +91,23 @@ Returns ``` HTTP/1.1 200 OK Content-Type: application/json -Content-Length: 22 -Date: Thu, 22 Dec 2016 07:35:28 GMT +Content-Length: 83 +Date: Thu, 05 Jan 2017 22:28:08 GMT Connection: close -"Done duplicating app" +{"result":"Done duplicating app","newAppId":"794e4003-aa89-4a4e-9120-7eb4d6314a32"} ``` +I.e. the JSON structure is + +```json +{ + "result": "Done duplicating app", + "newAppId":"794e4003-aa89-4a4e-9120-7eb4d6314a32" +} +``` + + ### Query Parameters ``` @@ -117,17 +127,7 @@ The new app will be reloaded (using the load script from the template app) befor curl -X GET "http://localhost:8000/duplicateKeepScript?appName=My%20new%20app&templateAppId=11111111-2222-3333-4444-555555555555&ownerUserId=joe" ``` -Returns - -``` -HTTP/1.1 200 OK -Content-Type: application/json -Content-Length: 22 -Date: Thu, 22 Dec 2016 07:35:28 GMT -Connection: close - -"Done duplicating app" -``` +The response from the service is exactly the same as for the /duplicateNewScript endpoint (see above). ### Query Parameters diff --git a/index.js b/index.js index a50236e..a257388 100644 --- a/index.js +++ b/index.js @@ -238,8 +238,9 @@ function respondDuplicateNewScript(req, res, next) { return globalEngine.connection.close(); }) .then(() => { - logger.log('info', 'Done duplicating'); - res.send('Done duplicating app'); + logger.log('info', 'Done duplicating, new app id=' + newAppId); + var jsonResult = {result:"Done duplicating app", newAppId:newAppId } + res.send(jsonResult); next(); }) .catch(err => { @@ -381,8 +382,9 @@ function respondDuplicateKeepScript(req, res, next) { return globalEngine.connection.close(); }) .then(() => { - logger.log('info', 'Done duplicating'); - res.send('Done duplicating app'); + logger.log('info', 'Done duplicating, new app id=' + newAppId); + var jsonResult = {result:"Done duplicating app", newAppId:newAppId } + res.send(jsonResult); next(); }) .catch(err => {