mirror of https://gitee.com/bigwinds/arangodb
better error handling
This commit is contained in:
parent
ad4f96be43
commit
865a402e3e
|
@ -97,12 +97,12 @@ string ActionDisptacherThread::_startupModules;
|
||||||
/// @brief constructs a new dispatcher thread
|
/// @brief constructs a new dispatcher thread
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ActionDisptacherThread::ActionDisptacherThread (DispatcherQueue* queue, string const& actionContext)
|
ActionDisptacherThread::ActionDisptacherThread (DispatcherQueue* queue, string const& actionQeue)
|
||||||
: DispatcherThread(queue),
|
: DispatcherThread(queue),
|
||||||
_report(false),
|
_report(false),
|
||||||
_isolate(0),
|
_isolate(0),
|
||||||
_context(),
|
_context(),
|
||||||
_actionContext(actionContext) {
|
_actionQeue(actionQeue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -254,7 +254,7 @@ void ActionDisptacherThread::initialise () {
|
||||||
_context->Enter();
|
_context->Enter();
|
||||||
|
|
||||||
TRI_InitV8VocBridge(_context, _vocbase);
|
TRI_InitV8VocBridge(_context, _vocbase);
|
||||||
TRI_InitV8Actions(_context, _actionContext.c_str());
|
TRI_InitV8Actions(_context, _actionQeue.c_str());
|
||||||
TRI_InitV8Conversions(_context);
|
TRI_InitV8Conversions(_context);
|
||||||
TRI_InitV8Utils(_context, _startupModules);
|
TRI_InitV8Utils(_context, _startupModules);
|
||||||
TRI_InitV8Shell(_context);
|
TRI_InitV8Shell(_context);
|
||||||
|
@ -283,10 +283,6 @@ void ActionDisptacherThread::initialise () {
|
||||||
|
|
||||||
if (! ok) {
|
if (! ok) {
|
||||||
LOGGER_FATAL << "cannot load actions from directory '" << loader->getDirectory() << "'";
|
LOGGER_FATAL << "cannot load actions from directory '" << loader->getDirectory() << "'";
|
||||||
cerr << "cannot load actions from directory '" << loader->getDirectory() << "'\n";
|
|
||||||
_context->Exit();
|
|
||||||
_isolate->Exit();
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace triagens {
|
||||||
/// @brief constructs a new dispatcher thread
|
/// @brief constructs a new dispatcher thread
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ActionDisptacherThread (rest::DispatcherQueue* queue, string const& actionContext);
|
ActionDisptacherThread (rest::DispatcherQueue* queue, string const& actionQeue);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief destructs a dispatcher thread
|
/// @brief destructs a dispatcher thread
|
||||||
|
@ -248,7 +248,7 @@ namespace triagens {
|
||||||
/// @brief action context
|
/// @brief action context
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::string _actionContext;
|
std::string _actionQeue;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -544,7 +544,7 @@ HttpResponse* TRI_ExecuteActionVocBase (TRI_vocbase_t* vocbase,
|
||||||
/// @brief stores the V8 actions function inside the global variable
|
/// @brief stores the V8 actions function inside the global variable
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void TRI_InitV8Actions (v8::Handle<v8::Context> context, char const* actionContext) {
|
void TRI_InitV8Actions (v8::Handle<v8::Context> context, char const* actionQeue) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
|
|
||||||
// check the isolate
|
// check the isolate
|
||||||
|
@ -560,8 +560,8 @@ void TRI_InitV8Actions (v8::Handle<v8::Context> context, char const* actionConte
|
||||||
// create the global constants
|
// create the global constants
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
context->Global()->Set(v8::String::New("SYS_ACTION_CONTEXT"),
|
context->Global()->Set(v8::String::New("SYS_ACTION_QUEUE"),
|
||||||
v8::String::New(actionContext),
|
v8::String::New(actionQeue),
|
||||||
v8::ReadOnly);
|
v8::ReadOnly);
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
|
@ -243,7 +243,7 @@ triagens::rest::HttpResponse* TRI_ExecuteActionVocBase (TRI_vocbase_t* vocbase,
|
||||||
/// @brief stores the V8 actions function inside the global variable
|
/// @brief stores the V8 actions function inside the global variable
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void TRI_InitV8Actions (v8::Handle<v8::Context> context, char const* actionContext);
|
void TRI_InitV8Actions (v8::Handle<v8::Context> context, char const* actionQeue);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
|
|
|
@ -638,6 +638,8 @@ static v8::Handle<v8::Value> JS_Execute (v8::Arguments const& argv) {
|
||||||
if (script.IsEmpty()) {
|
if (script.IsEmpty()) {
|
||||||
assert(tryCatch.HasCaught());
|
assert(tryCatch.HasCaught());
|
||||||
|
|
||||||
|
TRI_PrintV8Exception(&tryCatch);
|
||||||
|
|
||||||
if (useSandbox) {
|
if (useSandbox) {
|
||||||
context->DetachGlobal();
|
context->DetachGlobal();
|
||||||
context->Exit();
|
context->Exit();
|
||||||
|
@ -652,6 +654,8 @@ static v8::Handle<v8::Value> JS_Execute (v8::Arguments const& argv) {
|
||||||
if (result.IsEmpty()) {
|
if (result.IsEmpty()) {
|
||||||
assert(tryCatch.HasCaught());
|
assert(tryCatch.HasCaught());
|
||||||
|
|
||||||
|
TRI_PrintV8Exception(&tryCatch);
|
||||||
|
|
||||||
if (useSandbox) {
|
if (useSandbox) {
|
||||||
context->DetachGlobal();
|
context->DetachGlobal();
|
||||||
context->Exit();
|
context->Exit();
|
||||||
|
@ -1312,6 +1316,7 @@ bool TRI_LoadJavaScriptFile (v8::Handle<v8::Context> context, char const* filena
|
||||||
|
|
||||||
// compilation failed, print errors that happened during compilation
|
// compilation failed, print errors that happened during compilation
|
||||||
if (script.IsEmpty()) {
|
if (script.IsEmpty()) {
|
||||||
|
LOG_ERROR("cannot compile java script file '%s'", filename);
|
||||||
TRI_ReportV8Exception(&tryCatch);
|
TRI_ReportV8Exception(&tryCatch);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1323,6 +1328,7 @@ bool TRI_LoadJavaScriptFile (v8::Handle<v8::Context> context, char const* filena
|
||||||
assert(tryCatch.HasCaught());
|
assert(tryCatch.HasCaught());
|
||||||
|
|
||||||
// print errors that happened during execution
|
// print errors that happened during execution
|
||||||
|
LOG_ERROR("cannot execute java script file '%s'", filename);
|
||||||
TRI_ReportV8Exception(&tryCatch);
|
TRI_ReportV8Exception(&tryCatch);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
var actions = require("actions");
|
// var actions = require("actions");
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief geo "near" query
|
/// @brief geo "near" query
|
||||||
|
|
|
@ -1,82 +1,4 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief returns an error
|
|
||||||
///
|
|
||||||
/// @FUN{actionResultError(@FA{req}, @FA{res}, @FA{httpReturnCode}, @FA{errorNum}, @FA{errorMessage}, @FA{headers})}
|
|
||||||
///
|
|
||||||
/// The functions returns an error json object. The returned object is an array
|
|
||||||
/// with an attribute @LIT{errorMessage} containing the error message
|
|
||||||
/// @FA{errorMessage}.
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function actionResultError (req, res, httpReturnCode, errorNum, errorMessage, headers) {
|
|
||||||
res.responseCode = httpReturnCode;
|
|
||||||
res.contentType = "application/json";
|
|
||||||
|
|
||||||
var result = {
|
|
||||||
"error" : true,
|
|
||||||
"code" : httpReturnCode,
|
|
||||||
"errorNum" : errorNum,
|
|
||||||
"errorMessage" : errorMessage
|
|
||||||
}
|
|
||||||
|
|
||||||
res.body = JSON.stringify(result);
|
|
||||||
|
|
||||||
if (headers != undefined) {
|
|
||||||
res.headers = headers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief returns an error for unsupported methods
|
|
||||||
///
|
|
||||||
/// @FUN{actionResultUnsupported(@FA{req}, @FA{res}, @FA{headers})}
|
|
||||||
///
|
|
||||||
/// The functions returns an error json object. The returned object is an array
|
|
||||||
/// with an attribute @LIT{errorMessage} containing the error message
|
|
||||||
/// @FA{errorMessage}.
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function actionResultUnsupported (req, res, headers) {
|
|
||||||
actionResultError(req, res, 405, 405, "Unsupported method", headers);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief returns a result
|
|
||||||
///
|
|
||||||
/// @FUN{actionResultOK(@FA{req}, @FA{res}, @FA{httpReturnCode}, @FA{result}, @FA{headers}})}
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function actionResultOK (req, res, httpReturnCode, result, headers) {
|
|
||||||
res.responseCode = httpReturnCode;
|
|
||||||
res.contentType = "application/json";
|
|
||||||
|
|
||||||
// add some default attributes to result:
|
|
||||||
result.error = false;
|
|
||||||
result.code = httpReturnCode;
|
|
||||||
|
|
||||||
res.body = JSON.stringify(result);
|
|
||||||
|
|
||||||
if (headers != undefined) {
|
|
||||||
res.headers = headers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief error codes
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
var queryNotFound = 10404;
|
|
||||||
var queryNotModified = 10304;
|
|
||||||
|
|
||||||
var collectionNotFound = 20404;
|
|
||||||
var documentNotFound = 30404;
|
|
||||||
var documentNotModified = 30304;
|
|
||||||
|
|
||||||
var cursorNotFound = 40404;
|
|
||||||
var cursorNotModified = 40304;
|
|
||||||
|
|
||||||
var myApiRequests = {};
|
var myApiRequests = {};
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,14 @@ static string JS_bootstrap_modules =
|
||||||
" ModuleCache[path] = module = new Module(path);\n"
|
" ModuleCache[path] = module = new Module(path);\n"
|
||||||
"\n"
|
"\n"
|
||||||
" content = \"(function (module, exports, require, print) {\" + content + \"\\n});\";\n"
|
" content = \"(function (module, exports, require, print) {\" + content + \"\\n});\";\n"
|
||||||
|
"\n"
|
||||||
|
" try {\n"
|
||||||
" f = SYS_EXECUTE(content, undefined, path);\n"
|
" f = SYS_EXECUTE(content, undefined, path);\n"
|
||||||
|
" }\n"
|
||||||
|
" catch (err) {\n"
|
||||||
|
" CONSOLE_ERROR(\"in file %s: %o\", path, err.stack);\n"
|
||||||
|
" throw err;\n"
|
||||||
|
" }\n"
|
||||||
"\n"
|
"\n"
|
||||||
" if (f == undefined) {\n"
|
" if (f == undefined) {\n"
|
||||||
" throw \"cannot create context function\";\n"
|
" throw \"cannot create context function\";\n"
|
||||||
|
|
|
@ -101,7 +101,14 @@ Module.prototype.require = function (path) {
|
||||||
ModuleCache[path] = module = new Module(path);
|
ModuleCache[path] = module = new Module(path);
|
||||||
|
|
||||||
content = "(function (module, exports, require, print) {" + content + "\n});";
|
content = "(function (module, exports, require, print) {" + content + "\n});";
|
||||||
|
|
||||||
|
try {
|
||||||
f = SYS_EXECUTE(content, undefined, path);
|
f = SYS_EXECUTE(content, undefined, path);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
CONSOLE_ERROR("in file %s: %o", path, err.stack);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
if (f == undefined) {
|
if (f == undefined) {
|
||||||
throw "cannot create context function";
|
throw "cannot create context function";
|
||||||
|
|
|
@ -33,6 +33,11 @@ var console = require("console");
|
||||||
///
|
///
|
||||||
/// <ol>
|
/// <ol>
|
||||||
/// <li>@ref JSModuleActionsDefineHttp "defineHttp"</li>
|
/// <li>@ref JSModuleActionsDefineHttp "defineHttp"</li>
|
||||||
|
/// <li>@ref JSModuleActionsActionResult "actionResult"</li>
|
||||||
|
/// <li>@ref JSModuleActionsActionResultOK "actionResultOK"</li>
|
||||||
|
/// <li>@ref JSModuleActionsActionResultError "actionResultError"</li>
|
||||||
|
/// <li>@ref JSModuleActionsActionResultUnsupported "actionResultUnsupported"</li>
|
||||||
|
/// <li>@ref JSModuleActionsActionError "actionError"</li>
|
||||||
/// </ol>
|
/// </ol>
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -53,16 +58,55 @@ var console = require("console");
|
||||||
/// @copydetails JSF_actionResult
|
/// @copydetails JSF_actionResult
|
||||||
/// <hr>
|
/// <hr>
|
||||||
///
|
///
|
||||||
|
/// @anchor JSModuleActionsActionResultOK
|
||||||
|
/// @copydetails JSF_actionResultOK
|
||||||
|
/// <hr>
|
||||||
|
///
|
||||||
|
/// @anchor JSModuleActionsActionResultError
|
||||||
|
/// @copydetails JSF_actionResultError
|
||||||
|
/// <hr>
|
||||||
|
///
|
||||||
|
/// @anchor JSModuleActionsActionResultUnsupported
|
||||||
|
/// @copydetails JSF_actionResultUnsupported
|
||||||
|
/// <hr>
|
||||||
|
///
|
||||||
/// @anchor JSModuleActionsActionError
|
/// @anchor JSModuleActionsActionError
|
||||||
/// @copydetails JSF_actionError
|
/// @copydetails JSF_actionError
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- public constants
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup AvocadoActions
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief error codes
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
exports.queryNotFound = 10404;
|
||||||
|
exports.queryNotModified = 10304;
|
||||||
|
|
||||||
|
exports.collectionNotFound = 20404;
|
||||||
|
exports.documentNotFound = 30404;
|
||||||
|
exports.documentNotModified = 30304;
|
||||||
|
|
||||||
|
exports.cursorNotFound = 40404;
|
||||||
|
exports.cursorNotModified = 40304;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- public functions
|
// --SECTION-- public functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @addtogroup V8Json V8 JSON
|
/// @addtogroup AvocadoActions
|
||||||
/// @{
|
/// @{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -177,7 +221,7 @@ function defineHttp (options) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
internal.defineAction(url, queue, callback, parameter);
|
internal.defineAction(url, queue, callback, parameter);
|
||||||
console.debug("defining action '" + url + "' in context " + context " using queue " + queue);
|
console.debug("defining action '" + url + "' in context " + context + " using queue " + queue);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error("action '" + url + "' encountered error: " + err);
|
console.error("action '" + url + "' encountered error: " + err);
|
||||||
|
@ -224,6 +268,76 @@ function actionError (req, res, err) {
|
||||||
res.body = JSON.stringify({ 'error' : "" + err });
|
res.body = JSON.stringify({ 'error' : "" + err });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief returns a result
|
||||||
|
///
|
||||||
|
/// @FUN{actionResultOK(@FA{req}, @FA{res}, @FA{code}, @FA{result}, @FA{headers}})}
|
||||||
|
///
|
||||||
|
/// Works like @FN{actionResult} but adds the attribute @LIT{error} with
|
||||||
|
/// value @LIT{false} and @LIT{code} with value @FA{code} to the @FA{result}.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
function actionResultOK (req, res, httpReturnCode, result, headers) {
|
||||||
|
res.responseCode = httpReturnCode;
|
||||||
|
res.contentType = "application/json";
|
||||||
|
|
||||||
|
// add some default attributes to result
|
||||||
|
if (result == undefined) {
|
||||||
|
result = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
result.error = false;
|
||||||
|
result.code = httpReturnCode;
|
||||||
|
|
||||||
|
res.body = JSON.stringify(result);
|
||||||
|
|
||||||
|
if (headers != undefined) {
|
||||||
|
res.headers = headers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief returns an error
|
||||||
|
///
|
||||||
|
/// @FUN{actionResultError(@FA{req}, @FA{res}, @FA{code}, @FA{errorNum}, @FA{errorMessage}, @FA{headers})}
|
||||||
|
///
|
||||||
|
/// The functions generates an error response. The response body is an array
|
||||||
|
/// with an attribute @LIT{errorMessage} containing the error message
|
||||||
|
/// @FA{errorMessage}, @LIT{error} containing @LIT{true}, @LIT{code}
|
||||||
|
/// containing @FA{code}, @LIT{errorNum} containing @FA{errorNum}, and
|
||||||
|
/// $LIT{errorMessage} containing the error message @FA{errorMessage}.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
function actionResultError (req, res, httpReturnCode, errorNum, errorMessage, headers) {
|
||||||
|
res.responseCode = httpReturnCode;
|
||||||
|
res.contentType = "application/json";
|
||||||
|
|
||||||
|
var result = {
|
||||||
|
"error" : true,
|
||||||
|
"code" : httpReturnCode,
|
||||||
|
"errorNum" : errorNum,
|
||||||
|
"errorMessage" : errorMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
res.body = JSON.stringify(result);
|
||||||
|
|
||||||
|
if (headers != undefined) {
|
||||||
|
res.headers = headers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief returns an error for unsupported methods
|
||||||
|
///
|
||||||
|
/// @FUN{actionResultUnsupported(@FA{req}, @FA{res}, @FA{headers})}
|
||||||
|
///
|
||||||
|
/// The functions generates an error response.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
function actionResultUnsupported (req, res, headers) {
|
||||||
|
actionResultError(req, res, 405, 405, "Unsupported method", headers);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -233,11 +347,16 @@ function actionError (req, res, err) {
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @addtogroup AvocadoGraph
|
/// @addtogroup AvocadoActions
|
||||||
/// @{
|
/// @{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
exports.defineHttp = defineHttp;
|
exports.defineHttp = defineHttp;
|
||||||
|
exports.actionResult = actionResult;
|
||||||
|
exports.actionResultOK = actionResultOK;
|
||||||
|
exports.actionResultError = actionResultError;
|
||||||
|
exports.actionResultUnsupported = actionResultUnsupported;
|
||||||
|
exports.actionError = actionError;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Avocado Query Language
|
/// @brief Avocado Simple Query Language
|
||||||
///
|
///
|
||||||
/// @file
|
/// @file
|
||||||
///
|
///
|
||||||
/// DISCLAIMER
|
/// DISCLAIMER
|
||||||
///
|
///
|
||||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
/// Copyright 2012 triagens GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
/// you may not use this file except in compliance with the License.
|
/// you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief JavaScript actions modules
|
||||||
|
///
|
||||||
|
/// @file
|
||||||
|
///
|
||||||
|
/// DISCLAIMER
|
||||||
|
///
|
||||||
|
/// Copyright 2012 triagens GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
/// you may not use this file except in compliance with the License.
|
||||||
|
/// You may obtain a copy of the License at
|
||||||
|
///
|
||||||
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
///
|
||||||
|
/// Unless required by applicable law or agreed to in writing, software
|
||||||
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
/// See the License for the specific language governing permissions and
|
||||||
|
/// limitations under the License.
|
||||||
|
///
|
||||||
|
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// @author Dr. Frank Celler
|
||||||
|
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
var actions = require("actions");
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- private variables
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup AvocadoAPI
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
var API = "_api";
|
||||||
|
var ApiRequests = {};
|
||||||
|
|
||||||
|
ApiRequests.cursor = {
|
||||||
|
"POST /" + API + "/cursor" : "create and execute query. (creates a cursor)",
|
||||||
|
"PUT /" + API + "/cursor/<cursor-id>" : "get next results",
|
||||||
|
"DELETE /" + API + "/cursor/<cursor-id>" : "delete cursor"
|
||||||
|
}
|
||||||
|
|
||||||
|
ApiRequests.collection = {
|
||||||
|
"GET /" + API + "/collections" : "get list of collections",
|
||||||
|
"GET /" + API + "/collection/<collection-id>" : "get all elements of collection"
|
||||||
|
}
|
||||||
|
|
||||||
|
ApiRequests.document = {
|
||||||
|
"POST /" + API + "/document/<collection-id>" : "create new document",
|
||||||
|
"PUT /" + API + "/document/<collection-id>/<document-id>" : "update document",
|
||||||
|
"GET /" + API + "/document/<collection-id>/<document-id>" : "get a document",
|
||||||
|
"DELETE /" + API + "/document/<collection-id>/<document-id>" : "delete a document"
|
||||||
|
}
|
||||||
|
|
||||||
|
ApiRequests.query = {
|
||||||
|
"POST /" + API + "/query" : "create a query",
|
||||||
|
"GET /" + API + "/query/<query-id>" : "get query",
|
||||||
|
"PUT /" + API + "/query/<query-id>" : "change query",
|
||||||
|
"DELETE /" + API + "/query/<query-id>" : "delete query"
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- public functions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup AvocadoAPI
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief returns a help
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
actions.defineHttp({
|
||||||
|
url : API + "help",
|
||||||
|
context : "api",
|
||||||
|
|
||||||
|
callback : function (req, res) {
|
||||||
|
var result = {
|
||||||
|
requests : ApiRequests
|
||||||
|
}
|
||||||
|
|
||||||
|
actionResultOK(req, res, 200, result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- MODULE EXPORTS
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup AvocadoAPI
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
exports.apiPrefix = API;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: outline-minor
|
||||||
|
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
|
||||||
|
// End:
|
Loading…
Reference in New Issue