From 5c97c38b6e904cd9fe6fb4be63e856fdcbb6d36f Mon Sep 17 00:00:00 2001 From: Manuel Knitza Date: Mon, 11 Feb 2013 05:54:24 +0100 Subject: [PATCH 1/7] API: Query latest version --- src/node/handler/APIHandler.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js index 9f86277a0..26849605f 100644 --- a/src/node/handler/APIHandler.js +++ b/src/node/handler/APIHandler.js @@ -40,7 +40,8 @@ catch(e) //a list of all functions var version = { "1": - { "createGroup" : [] + { "getLatestApiVersion" : [] + , "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] , "listPads" : ["groupID"] @@ -70,7 +71,8 @@ var version = , "padUsersCount" : ["padID"] } , "1.1": - { "createGroup" : [] + { "getLatestApiVersion" : [] + , "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] , "listPads" : ["groupID"] @@ -104,7 +106,8 @@ var version = , "listAllGroups" : [] } , "1.2": - { "createGroup" : [] + { "getLatestApiVersion" : [] + , "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] , "listPads" : ["groupID"] @@ -139,7 +142,8 @@ var version = , "checkToken" : [] } , "1.2.1": - { "createGroup" : [] + { "getLatestApiVersion" : [] + , "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] , "listPads" : ["groupID"] @@ -175,7 +179,8 @@ var version = , "checkToken" : [] } , "1.2.7": - { "createGroup" : [] + { "getLatestApiVersion" : [] + , "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] , "listPads" : ["groupID"] @@ -216,6 +221,13 @@ var version = } }; +// This sets the latest available API version +var latestApiVersion = null; +for(var knownApiVersion in version) +{ + latestApiVersion = knownApiVersion; +} + /** * Handles a HTTP API call * @param functionName the name of the called function @@ -288,6 +300,11 @@ exports.handle = function(apiVersion, functionName, fields, req, res) } else { + if(functionName == "getLatestApiVersion") + { + res.send({code: 0, message: "latest API version", data: latestApiVersion}); + return; + } callAPI(apiVersion, functionName, fields, req, res); } } From 26f7ae0e5501521550bc3ab56f18ad09a02adc0f Mon Sep 17 00:00:00 2001 From: Manuel Knitza Date: Tue, 12 Feb 2013 21:21:10 +0100 Subject: [PATCH 2/7] Update src/node/handler/APIHandler.js --- src/node/handler/APIHandler.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js index 26849605f..65cc3ca7e 100644 --- a/src/node/handler/APIHandler.js +++ b/src/node/handler/APIHandler.js @@ -40,8 +40,7 @@ catch(e) //a list of all functions var version = { "1": - { "getLatestApiVersion" : [] - , "createGroup" : [] + { "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] , "listPads" : ["groupID"] @@ -71,8 +70,7 @@ var version = , "padUsersCount" : ["padID"] } , "1.1": - { "getLatestApiVersion" : [] - , "createGroup" : [] + { "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] , "listPads" : ["groupID"] @@ -106,8 +104,7 @@ var version = , "listAllGroups" : [] } , "1.2": - { "getLatestApiVersion" : [] - , "createGroup" : [] + { "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] , "listPads" : ["groupID"] @@ -142,8 +139,7 @@ var version = , "checkToken" : [] } , "1.2.1": - { "getLatestApiVersion" : [] - , "createGroup" : [] + { "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] , "listPads" : ["groupID"] @@ -179,8 +175,7 @@ var version = , "checkToken" : [] } , "1.2.7": - { "getLatestApiVersion" : [] - , "createGroup" : [] + { "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] , "listPads" : ["groupID"] @@ -221,12 +216,8 @@ var version = } }; -// This sets the latest available API version -var latestApiVersion = null; -for(var knownApiVersion in version) -{ - latestApiVersion = knownApiVersion; -} +// sets the latest available API version here +exports.latestApiVersion = '1.2.7'; /** * Handles a HTTP API call From e59496fbe700c95903be9167b62a3e69d3a11c4c Mon Sep 17 00:00:00 2001 From: Manuel Knitza Date: Tue, 12 Feb 2013 21:28:42 +0100 Subject: [PATCH 3/7] Update src/node/hooks/express/apicalls.js --- src/node/hooks/express/apicalls.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/node/hooks/express/apicalls.js b/src/node/hooks/express/apicalls.js index e57e1d350..ae250701d 100644 --- a/src/node/hooks/express/apicalls.js +++ b/src/node/hooks/express/apicalls.js @@ -57,4 +57,10 @@ exports.expressCreateServer = function (hook_name, args, cb) { res.end("OK"); }); }); + + //Provide a possibility to query the latest available API version + args.app.get('/api', function (req, res) { + res.json({"latestApiVersion" : apiHandler.latestAPI}); + }); + } From e5525d4e1672b6d813f37ff6943f9c3b4dc506a3 Mon Sep 17 00:00:00 2001 From: Manuel Knitza Date: Tue, 12 Feb 2013 21:29:32 +0100 Subject: [PATCH 4/7] Update src/node/hooks/express/apicalls.js --- src/node/hooks/express/apicalls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/hooks/express/apicalls.js b/src/node/hooks/express/apicalls.js index ae250701d..a36ecf4d7 100644 --- a/src/node/hooks/express/apicalls.js +++ b/src/node/hooks/express/apicalls.js @@ -60,7 +60,7 @@ exports.expressCreateServer = function (hook_name, args, cb) { //Provide a possibility to query the latest available API version args.app.get('/api', function (req, res) { - res.json({"latestApiVersion" : apiHandler.latestAPI}); + res.json({"latestApiVersion" : apiHandler.latestApiVersion}); }); } From 3bb475515a4013a170e7875ea1988bcd242aa3a5 Mon Sep 17 00:00:00 2001 From: Manuel Knitza Date: Tue, 12 Feb 2013 21:32:01 +0100 Subject: [PATCH 5/7] Update src/node/hooks/express/apicalls.js --- src/node/hooks/express/apicalls.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/node/hooks/express/apicalls.js b/src/node/hooks/express/apicalls.js index a36ecf4d7..8b066b6d5 100644 --- a/src/node/hooks/express/apicalls.js +++ b/src/node/hooks/express/apicalls.js @@ -62,5 +62,4 @@ exports.expressCreateServer = function (hook_name, args, cb) { args.app.get('/api', function (req, res) { res.json({"latestApiVersion" : apiHandler.latestApiVersion}); }); - } From 4d65c41dfb745ab0b2a90da9913ae0bd2d0cc5de Mon Sep 17 00:00:00 2001 From: Manuel Knitza Date: Tue, 12 Feb 2013 21:37:09 +0100 Subject: [PATCH 6/7] Update src/node/handler/APIHandler.js --- src/node/handler/APIHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js index 65cc3ca7e..722619e52 100644 --- a/src/node/handler/APIHandler.js +++ b/src/node/handler/APIHandler.js @@ -216,7 +216,7 @@ var version = } }; -// sets the latest available API version here +// set the latest available API version here exports.latestApiVersion = '1.2.7'; /** From 65f1b9c6aa657973cab1c6e165432f99d71051a5 Mon Sep 17 00:00:00 2001 From: Manuel Knitza Date: Tue, 12 Feb 2013 21:38:54 +0100 Subject: [PATCH 7/7] Update src/node/hooks/express/apicalls.js --- src/node/hooks/express/apicalls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/hooks/express/apicalls.js b/src/node/hooks/express/apicalls.js index 8b066b6d5..0971a877b 100644 --- a/src/node/hooks/express/apicalls.js +++ b/src/node/hooks/express/apicalls.js @@ -60,6 +60,6 @@ exports.expressCreateServer = function (hook_name, args, cb) { //Provide a possibility to query the latest available API version args.app.get('/api', function (req, res) { - res.json({"latestApiVersion" : apiHandler.latestApiVersion}); + res.json({"currentVersion" : apiHandler.latestApiVersion}); }); }