move copy/move pad into a new api version
parent
8b821d42a2
commit
45e0680484
|
@ -31,7 +31,7 @@ try
|
||||||
{
|
{
|
||||||
apikey = fs.readFileSync("./APIKEY.txt","utf8");
|
apikey = fs.readFileSync("./APIKEY.txt","utf8");
|
||||||
}
|
}
|
||||||
catch(e)
|
catch(e)
|
||||||
{
|
{
|
||||||
apikey = randomString(32);
|
apikey = randomString(32);
|
||||||
fs.writeFileSync("./APIKEY.txt",apikey,"utf8");
|
fs.writeFileSync("./APIKEY.txt",apikey,"utf8");
|
||||||
|
@ -215,6 +215,48 @@ var version =
|
||||||
, "getChatHead" : ["padID"]
|
, "getChatHead" : ["padID"]
|
||||||
}
|
}
|
||||||
, "1.2.8":
|
, "1.2.8":
|
||||||
|
{ "createGroup" : []
|
||||||
|
, "createGroupIfNotExistsFor" : ["groupMapper"]
|
||||||
|
, "deleteGroup" : ["groupID"]
|
||||||
|
, "listPads" : ["groupID"]
|
||||||
|
, "listAllPads" : []
|
||||||
|
, "createDiffHTML" : ["padID", "startRev", "endRev"]
|
||||||
|
, "createPad" : ["padID", "text"]
|
||||||
|
, "createGroupPad" : ["groupID", "padName", "text"]
|
||||||
|
, "createAuthor" : ["name"]
|
||||||
|
, "createAuthorIfNotExistsFor": ["authorMapper" , "name"]
|
||||||
|
, "listPadsOfAuthor" : ["authorID"]
|
||||||
|
, "createSession" : ["groupID", "authorID", "validUntil"]
|
||||||
|
, "deleteSession" : ["sessionID"]
|
||||||
|
, "getSessionInfo" : ["sessionID"]
|
||||||
|
, "listSessionsOfGroup" : ["groupID"]
|
||||||
|
, "listSessionsOfAuthor" : ["authorID"]
|
||||||
|
, "getText" : ["padID", "rev"]
|
||||||
|
, "setText" : ["padID", "text"]
|
||||||
|
, "getHTML" : ["padID", "rev"]
|
||||||
|
, "setHTML" : ["padID", "html"]
|
||||||
|
, "getAttributePool" : ["padID"]
|
||||||
|
, "getRevisionsCount" : ["padID"]
|
||||||
|
, "getRevisionChangeset" : ["padID", "rev"]
|
||||||
|
, "getLastEdited" : ["padID"]
|
||||||
|
, "deletePad" : ["padID"]
|
||||||
|
, "getReadOnlyID" : ["padID"]
|
||||||
|
, "setPublicStatus" : ["padID", "publicStatus"]
|
||||||
|
, "getPublicStatus" : ["padID"]
|
||||||
|
, "setPassword" : ["padID", "password"]
|
||||||
|
, "isPasswordProtected" : ["padID"]
|
||||||
|
, "listAuthorsOfPad" : ["padID"]
|
||||||
|
, "padUsersCount" : ["padID"]
|
||||||
|
, "getAuthorName" : ["authorID"]
|
||||||
|
, "padUsers" : ["padID"]
|
||||||
|
, "sendClientsMessage" : ["padID", "msg"]
|
||||||
|
, "listAllGroups" : []
|
||||||
|
, "checkToken" : []
|
||||||
|
, "getChatHistory" : ["padID"]
|
||||||
|
, "getChatHistory" : ["padID", "start", "end"]
|
||||||
|
, "getChatHead" : ["padID"]
|
||||||
|
}
|
||||||
|
, "1.2.9":
|
||||||
{ "createGroup" : []
|
{ "createGroup" : []
|
||||||
, "createGroupIfNotExistsFor" : ["groupMapper"]
|
, "createGroupIfNotExistsFor" : ["groupMapper"]
|
||||||
, "deleteGroup" : ["groupID"]
|
, "deleteGroup" : ["groupID"]
|
||||||
|
@ -261,7 +303,7 @@ var version =
|
||||||
};
|
};
|
||||||
|
|
||||||
// set the latest available API version here
|
// set the latest available API version here
|
||||||
exports.latestApiVersion = '1.2.7';
|
exports.latestApiVersion = '1.2.9';
|
||||||
|
|
||||||
// exports the versions so it can be used by the new Swagger endpoint
|
// exports the versions so it can be used by the new Swagger endpoint
|
||||||
exports.version = version;
|
exports.version = version;
|
||||||
|
@ -285,7 +327,7 @@ exports.handle = function(apiVersion, functionName, fields, req, res)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//say goodbye if this is an unkown API version
|
//say goodbye if this is an unkown API version
|
||||||
if(!isKnownApiVersion)
|
if(!isKnownApiVersion)
|
||||||
{
|
{
|
||||||
|
@ -293,7 +335,7 @@ exports.handle = function(apiVersion, functionName, fields, req, res)
|
||||||
res.send({code: 3, message: "no such api version", data: null});
|
res.send({code: 3, message: "no such api version", data: null});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if this is a valid function name
|
//check if this is a valid function name
|
||||||
var isKnownFunctionname = false;
|
var isKnownFunctionname = false;
|
||||||
for(var knownFunctionname in version[apiVersion])
|
for(var knownFunctionname in version[apiVersion])
|
||||||
|
@ -304,17 +346,17 @@ exports.handle = function(apiVersion, functionName, fields, req, res)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//say goodbye if this is a unkown function
|
//say goodbye if this is a unkown function
|
||||||
if(!isKnownFunctionname)
|
if(!isKnownFunctionname)
|
||||||
{
|
{
|
||||||
res.send({code: 3, message: "no such function", data: null});
|
res.send({code: 3, message: "no such function", data: null});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check the api key!
|
//check the api key!
|
||||||
fields["apikey"] = fields["apikey"] || fields["api_key"];
|
fields["apikey"] = fields["apikey"] || fields["api_key"];
|
||||||
|
|
||||||
if(fields["apikey"] != apikey.trim())
|
if(fields["apikey"] != apikey.trim())
|
||||||
{
|
{
|
||||||
res.send({code: 4, message: "no or wrong API Key", data: null});
|
res.send({code: 4, message: "no or wrong API Key", data: null});
|
||||||
|
@ -351,16 +393,16 @@ function callAPI(apiVersion, functionName, fields, req, res)
|
||||||
var functionParams = version[apiVersion][functionName].map(function (field) {
|
var functionParams = version[apiVersion][functionName].map(function (field) {
|
||||||
return fields[field]
|
return fields[field]
|
||||||
})
|
})
|
||||||
|
|
||||||
//add a callback function to handle the response
|
//add a callback function to handle the response
|
||||||
functionParams.push(function(err, data)
|
functionParams.push(function(err, data)
|
||||||
{
|
{
|
||||||
// no error happend, everything is fine
|
// no error happend, everything is fine
|
||||||
if(err == null)
|
if(err == null)
|
||||||
{
|
{
|
||||||
if(!data)
|
if(!data)
|
||||||
data = null;
|
data = null;
|
||||||
|
|
||||||
res.send({code: 0, message: "ok", data: data});
|
res.send({code: 0, message: "ok", data: data});
|
||||||
}
|
}
|
||||||
// parameters were wrong and the api stopped execution, pass the error
|
// parameters were wrong and the api stopped execution, pass the error
|
||||||
|
@ -375,7 +417,7 @@ function callAPI(apiVersion, functionName, fields, req, res)
|
||||||
ERR(err);
|
ERR(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//call the api function
|
//call the api function
|
||||||
api[functionName].apply(this, functionParams);
|
api[functionName].apply(this, functionParams);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue