ArangoDB v3.4 reached End of Life (EOL) and is no longer supported.
This documentation is outdated. Please see the most recent version here: Latest Docs
Request objects
The names of some attributes of the request object have been adjusted to more closely align with those of the corresponding methods on the endpoint objects and established conventions in other JavaScript frameworks:
-
req.urlParametersis now calledreq.pathParams -
req.parametersis now calledreq.queryParams -
req.params()is now calledreq.param() -
req.requestTypeis now calledreq.method -
req.compatibilityis now calledreq.arangoVersion -
req.useris now calledreq.arangoUser
Some attributes have been removed or changed:
-
req.cookieshas been removed entirely (usereq.cookie(name)) -
req.requestBodyhas been removed entirely (see below) -
req.suffixis now a string rather than an array
Additionally the req.server and req.client attributes are no longer available. The information is now exposed in a way that can (optionally) transparently handle proxy forwarding headers:
-
req.hostnamedefaults toreq.server.address -
req.portdefaults toreq.server.port -
req.remoteAddressdefaults toclient.address -
req.remotePortdefaults toclient.port
Finally, the req.cookie method now takes the signed options directly.
Old:
const sid = req.cookie('sid', {
signed: {
secret: 'keyboardcat',
algorithm: 'sha256'
}
});
New:
const sid = req.cookie('sid', {
secret: 'keyboardcat',
algorithm: 'sha256'
});
Request bodies
The req.body is no longer a method and no longer automatically parses JSON request bodies unless a request body was defined. The req.rawBody now corresponds to the req.rawBodyBuffer of ArangoDB 2.x and is also no longer a method.
Old:
ctrl.post('/', function (req, res) {
const data = req.body();
// ...
});
New:
router.post('/', function (req, res) {
const data = req.body;
// ...
})
.body(['json']);
Or simply:
const joi = require('joi');
router.post('/', function (req, res) {
const data = req.body;
// ...
})
.body(joi.object().optional());
Multipart requests
The req.requestParts method has been removed entirely. If you need to accept multipart request bodies, you can simply define the request body using a multipart MIME type like multipart/form-data:
Old:
ctrl.post('/', function (req, res) {
const parts = req.requestParts();
// ...
});
New:
router.post('/', function (req, res) {
const parts = req.body;
// ...
})
.body(['multipart/form-data']);