1
0
Fork 0

Merge branch 'devel' of github.com:arangodb/arangodb into devel

This commit is contained in:
hkernbach 2016-04-20 15:48:21 +02:00
commit 972367b4f7
67 changed files with 296 additions and 117 deletions

View File

@ -225,6 +225,44 @@ TRI_doc_mptr_t* EdgeIndexIterator::next() {
}
}
void EdgeIndexIterator::nextBabies(std::vector<TRI_doc_mptr_t*>& buffer, size_t limit) {
size_t atMost = _batchSize > limit ? limit : _batchSize;
while (true) {
if (_position >= static_cast<size_t>(_keys.length())) {
// we're at the end of the lookup values
buffer.clear();
return;
}
if (buffer.empty()) {
VPackSlice tmp = _keys.at(_position);
if (tmp.isObject()) {
tmp = tmp.get(TRI_SLICE_KEY_EQUAL);
}
_index->lookupByKey(_trx, &tmp, buffer, atMost);
// fallthrough intentional
} else {
// Continue the lookup
auto last = buffer.back();
buffer.clear();
_index->lookupByKeyContinue(_trx, last, buffer, atMost);
}
if (!buffer.empty()) {
// found something
return;
//return buffer.at(_posInBuffer++);
}
// found no result. now go to next lookup value in _keys
++_position;
}
}
void EdgeIndexIterator::reset() {
_position = 0;
_posInBuffer = 0;

View File

@ -41,6 +41,8 @@ class EdgeIndexIterator final : public IndexIterator {
TRI_doc_mptr_t* next() override;
void nextBabies(std::vector<TRI_doc_mptr_t*>&, size_t) override;
void reset() override;
EdgeIndexIterator(arangodb::Transaction* trx,

View File

@ -93,6 +93,14 @@ IndexIterator::~IndexIterator() {}
TRI_doc_mptr_t* IndexIterator::next() { return nullptr; }
////////////////////////////////////////////////////////////////////////////////
/// @brief default implementation for nextBabies
////////////////////////////////////////////////////////////////////////////////
void IndexIterator::nextBabies(std::vector<TRI_doc_mptr_t*>&, size_t) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief default implementation for reset
////////////////////////////////////////////////////////////////////////////////

View File

@ -68,6 +68,8 @@ class IndexIterator {
virtual TRI_doc_mptr_t* next();
virtual void nextBabies(std::vector<TRI_doc_mptr_t*>&, size_t);
virtual void reset();
virtual void skip(uint64_t count, uint64_t& skipped);

View File

@ -63,6 +63,7 @@ void OperationCursor::getMore(std::shared_ptr<OperationResult>& opRes,
TRI_ASSERT(false);
// You requested more even if you should have checked it before.
opRes->code = TRI_ERROR_FORBIDDEN;
return;
}
if (batchSize == UINT64_MAX) {
batchSize = _batchSize;
@ -93,6 +94,69 @@ void OperationCursor::getMore(std::shared_ptr<OperationResult>& opRes,
}
}
//////////////////////////////////////////////////////////////////////////////
/// @brief Get next batchSize many elements. mptr variant
/// Defaults to _batchSize
/// Check hasMore()==true before using this
/// NOTE: This will throw on OUT_OF_MEMORY
//////////////////////////////////////////////////////////////////////////////
std::vector<TRI_doc_mptr_t*> OperationCursor::getMoreMptr(uint64_t batchSize) {
std::vector<TRI_doc_mptr_t*> res;
getMoreMptr(res, batchSize);
return res;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief Get next batchSize many elements. mptr variant
/// Defaults to _batchSize
/// Check hasMore()==true before using this
/// NOTE: This will throw on OUT_OF_MEMORY
/// NOTE: The result vector handed in is used to continue index lookups
/// The caller shall NOT modify it.
//////////////////////////////////////////////////////////////////////////////
void OperationCursor::getMoreMptr(std::vector<TRI_doc_mptr_t*>& result,
uint64_t batchSize) {
if (!hasMore()) {
TRI_ASSERT(false);
// You requested more even if you should have checked it before.
return;
}
if (batchSize == UINT64_MAX) {
batchSize = _batchSize;
}
size_t atMost = batchSize > _limit ? _limit : batchSize;
_indexIterator->nextBabies(result, atMost);
size_t got = result.size();
if (got == 0) {
// Index is empty
_hasMore = false;
return;
}
// NOTE: None of these could fall below zero
batchSize -= got;
_limit -= got;
/*
// result.clear();
// TODO: Improve this for baby awareness
TRI_doc_mptr_t* mptr = nullptr;
while (batchSize > 0 && _limit > 0 && (mptr = _indexIterator->next()) != nullptr) {
--batchSize;
--_limit;
result.emplace_back(mptr);
}
*/
if (batchSize > 0 || _limit == 0) {
// Iterator empty, there is no more
_hasMore = false;
}
}
//////////////////////////////////////////////////////////////////////////////
/// @brief Skip the next toSkip many elements.
/// skipped will be increased by the amount of skipped elements afterwards

View File

@ -122,6 +122,25 @@ struct OperationCursor {
void getMore(std::shared_ptr<OperationResult>&, uint64_t batchSize = UINT64_MAX,
bool useExternals = false);
//////////////////////////////////////////////////////////////////////////////
/// @brief Get next batchSize many elements. mptr variant
/// Defaults to _batchSize
/// Check hasMore()==true before using this
/// NOTE: This will throw on OUT_OF_MEMORY
//////////////////////////////////////////////////////////////////////////////
std::vector<TRI_doc_mptr_t*> getMoreMptr(uint64_t batchSize);
//////////////////////////////////////////////////////////////////////////////
/// @brief Get next batchSize many elements. mptr variant
/// Defaults to _batchSize
/// Check hasMore()==true before using this
/// NOTE: This will throw on OUT_OF_MEMORY
/// NOTE: The result vector handed in will be cleared.
//////////////////////////////////////////////////////////////////////////////
void getMoreMptr(std::vector<TRI_doc_mptr_t*>& result, uint64_t batchSize);
//////////////////////////////////////////////////////////////////////////////
/// @brief Skip the next toSkip many elements.
/// skipped will be increased by the amount of skipped elements afterwards

View File

@ -1283,7 +1283,7 @@ OperationResult Transaction::insertLocal(std::string const& collectionName,
VPackArrayIterator itValue(value);
VPackArrayIterator itResult(ourResult);
while (itValue.valid() && itResult.valid()) {
TRI_ASSERT(itResult->isObject());
TRI_ASSERT((*itResult).isObject());
if (!(*itResult).hasKey("error")) {
doOneDoc(itValue.value(), itResult.value());
count++;

View File

@ -665,7 +665,7 @@ static void OutboundNeighbors(std::vector<EdgeCollectionInfo*>& collectionInfos,
uint64_t depth = 1) {
TRI_edge_direction_e dir = TRI_EDGE_OUT;
std::unordered_set<std::string> nextDepth;
auto opRes = std::make_shared<OperationResult>(TRI_ERROR_NO_ERROR);
std::vector<TRI_doc_mptr_t*> cursor;
for (auto const& col : collectionInfos) {
TRI_ASSERT(col != nullptr);
@ -673,12 +673,9 @@ static void OutboundNeighbors(std::vector<EdgeCollectionInfo*>& collectionInfos,
for (auto const& start : startVertices) {
auto edgeCursor = col->getEdges(dir, start);
while (edgeCursor->hasMore()) {
edgeCursor->getMore(opRes, UINT64_MAX, false);
if (opRes->failed()) {
THROW_ARANGO_EXCEPTION(opRes->code);
}
VPackSlice edges = opRes->slice();
for (auto const& edge : VPackArrayIterator(edges)) {
edgeCursor->getMoreMptr(cursor, UINT64_MAX);
for (auto const& mptr : cursor) {
VPackSlice edge(mptr->vpack());
if (opts.matchesEdge(edge)) {
VPackValueLength l;
char const* v = edge.get(TRI_VOC_ATTRIBUTE_TO).getString(l);

View File

@ -29,6 +29,7 @@ const dd = require('dedent');
const internal = require('internal');
const db = require('@arangodb').db;
const errors = require('@arangodb').errors;
const joinPath = require('path').posix.join;
const notifications = require('@arangodb/configuration').notifications;
const examples = require('@arangodb/graph-examples/example-graph');
const createRouter = require('@arangodb/foxx/router');
@ -44,9 +45,8 @@ module.exports = router;
router.get('/whoAmI', function(req, res) {
let user = null;
if (internal.options()['server.disable-authentication']) {
user = false;
} else if (req.session && req.session.uid) {
if (req.session.uid) {
try {
const doc = db._users.document(req.session.uid);
user = doc.user;
@ -57,6 +57,7 @@ router.get('/whoAmI', function(req, res) {
sessions.setUser(req.session, null);
}
}
res.json({user});
})
.summary('Return the current user')
@ -78,8 +79,16 @@ router.post('/logout', function (req, res) {
router.post('/login', function (req, res) {
if (!req.session) {
req.session = sessions.new();
const currentDb = db._name();
const actualDb = req.body.database;
if (actualDb !== currentDb) {
res.redirect(307, joinPath(
'/_db',
encodeURIComponent(actualDb),
module.context.mount,
'/login'
));
return;
}
const doc = db._users.firstExample({user: req.body.username});
@ -94,12 +103,14 @@ router.post('/login', function (req, res) {
sessions.setUser(req.session, doc);
sessions.save(req.session);
const user = doc.user;
res.json({user});
})
.body({
username: joi.string().required(),
password: joi.string().required().allow('')
password: joi.string().required().allow(''),
database: joi.string().default(db._name())
}, 'Login credentials.')
.error('unauthorized', 'Invalid credentials.')
.summary('Log in')
@ -114,7 +125,7 @@ router.use(authRouter);
authRouter.use((req, res, next) => {
if (!internal.options()['server.disable-authentication'] && (!req.session || !req.session.uid)) {
if (!req.session.uid) {
res.throw('unauthorized');
}
next();
@ -191,16 +202,12 @@ authRouter.post('/query/explain', function(req, res) {
authRouter.post('/query/upload/:user', function(req, res) {
let doc;
if (req.session && req.session.uid) {
try {
doc = db._users.document(req.session.uid);
} catch (e) {
if (!e.isArangoError || e.errorNum !== errors.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code) {
throw e;
}
try {
doc = db._users.document(req.session.uid);
} catch (e) {
if (!e.isArangoError || e.errorNum !== errors.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code) {
throw e;
}
} else {
doc = db._users.firstExample({user: req.pathParams.user});
}
if (!doc) {
@ -240,16 +247,12 @@ authRouter.post('/query/upload/:user', function(req, res) {
authRouter.get('/query/download/:user', function(req, res) {
let doc;
if (req.session && req.session.uid) {
try {
doc = db._users.document(req.session.uid);
} catch (e) {
if (!e.isArangoError || e.errorNum !== errors.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code) {
throw e;
}
try {
doc = db._users.document(req.session.uid);
} catch (e) {
if (!e.isArangoError || e.errorNum !== errors.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code) {
throw e;
}
} else {
doc = db._users.firstExample({user: req.pathParams.user});
}
if (!doc) {

View File

@ -28,14 +28,13 @@ const _ = require('lodash');
const dd = require('dedent');
const cluster = require('@arangodb/cluster');
const createRouter = require('@arangodb/foxx/router');
const internal = require('internal');
const router = createRouter();
module.exports = router;
router.use((req, res, next) => {
if (!internal.options()['server.disable-authentication'] && (!req.session || !req.session.uid)) {
if (!req.session.uid) {
res.throw('unauthorized');
}
next();

View File

@ -28,7 +28,6 @@ const fs = require('fs');
const joi = require('joi');
const dd = require('dedent');
const marked = require('marked');
const internal = require('internal');
const highlightAuto = require('highlight.js').highlightAuto;
const FoxxManager = require('@arangodb/foxx/manager');
const fmUtils = require('@arangodb/foxx/manager-utils');
@ -41,7 +40,7 @@ module.exports = router;
router.use((req, res, next) => {
if (!internal.options()['server.disable-authentication'] && (!req.session || !req.session.uid)) {
if (!req.session.uid) {
res.throw('unauthorized');
}
next();

View File

@ -32,11 +32,17 @@ module.context.sessions = systemStorage();
module.context.auth = auth('sha256');
module.context.use(sessionsMiddleware({
autoCreate: false,
transport: cookieTransport(`arango_sid_${db._name()}`),
storage: module.context.sessions
}));
module.context.use((req, res, next) => {
if (module.context.configuration.sessionPruneProb > Math.random()) {
module.context.sessions.prune();
}
next();
});
module.context.use(require('./aardvark'));
module.context.use('/foxxes', require('./foxxes'));
module.context.use('/cluster', require('./cluster'));

View File

@ -32,6 +32,14 @@
"main": "index.js",
"defaultDocument": "index.html",
"configuration": {
"sessionPruneProb": {
"description": "Probability that dead sessions will be removed from the database for any given request.",
"type": "number",
"default": "0.001"
}
},
"files": {
"/index.html": {
"path": "frontend/build/standalone-min.html",

View File

@ -395,7 +395,7 @@ function computeStatisticsLong (attrs, clusterId) {
router.use((req, res, next) => {
if (!internal.options()['server.disable-authentication'] && (!req.session || !req.session.uid)) {
if (!req.session.uid) {
throw new httperr.Unauthorized();
}
next();

View File

@ -110,7 +110,7 @@ global.db = require("@arangodb").db;
/// @brief template string generator for building an AQL query
////////////////////////////////////////////////////////////////////////////////
global.aqlQuery = require("@arangodb").aql;
global.aql = global.aqlQuery = require("@arangodb").aql;
////////////////////////////////////////////////////////////////////////////////
/// @brief global 'arango'

View File

@ -968,7 +968,7 @@ function runInArangosh(options, instanceInfo, file, addArgs) {
args["javascript.unit-tests"] = fs.join(TOP_DIR, file);
if (addArgs !== undefined) {
args = _.extend(args, addArgs);
args = Object.assign(args, addArgs);
}
let rc = executeAndWait(ARANGOSH_BIN, toArgv(args), options);
@ -998,7 +998,7 @@ function runArangoshCmd(options, instanceInfo, addArgs, cmds) {
args["server.endpoint"] = instanceInfo.endpoint;
if (addArgs !== undefined) {
args = _.extend(args, addArgs);
args = Object.assign(args, addArgs);
}
const argv = toArgv(args).concat(cmds);
@ -1075,7 +1075,7 @@ function runArangoBenchmark(options, instanceInfo, cmds) {
"server.connection-timeout": 10 // 5s default
};
args = _.extend(args, cmds);
args = Object.assign(args, cmds);
if (!args.hasOwnProperty('verbose')) {
args.quiet = true;
@ -1208,7 +1208,7 @@ function startInstanceCluster(instanceInfo, protocol, options,
fs.makeDirectoryRecursive(subDir);
let subArgs = makeArgsArangod(options, fs.join(subDir, "apps"));
subArgs = _.extend(subArgs, args);
subArgs = Object.assign(subArgs, args);
return [subArgs, name, subDir];
};
@ -1319,10 +1319,10 @@ function startArango(protocol, options, addArgs, name, rootDir, isAgency) {
args["server.keyfile"] = fs.join("UnitTests", "server.pem");
}
args = _.extend(args, options.extraArgs);
args = Object.assign(args, options.extraArgs);
if (addArgs !== undefined) {
args = _.extend(args, addArgs);
args = Object.assign(args, addArgs);
}
instanceInfo.url = endpointToURL(instanceInfo.endpoint);
@ -2089,7 +2089,7 @@ testFuncs.arangob = function(options) {
delete args.transaction;
if (options.hasOwnProperty('benchargs')) {
args = _.extend(args, options.benchargs);
args = Object.assign(args, options.benchargs);
}
let oneResult = runArangoBenchmark(options, instanceInfo, args);

View File

@ -44,9 +44,14 @@ exports.aql = function () {
let strings = arguments[0];
const bindVars = {};
let query = strings[0];
let j = 0;
for (let i = 1; i < arguments.length; i++) {
let value = arguments[i];
let name = `value${i - 1}`;
if (value && typeof value.toAQL === 'function') {
query += value.toAQL();
continue;
}
let name = `value${j++}`;
if (value && value.isArangoCollection) {
name = `@${name}`;
value = value.name();

View File

@ -567,7 +567,7 @@ AQLGenerator.prototype.neighbors = function(vertexExample, options) {
+ this.stack.length + ')';
var opts;
if (options) {
opts = _.extend({}, options);
opts = Object.assign({}, options);
} else {
opts = {};
}
@ -1343,7 +1343,7 @@ var _renameCollection = function(oldName, newName) {
return;
}
gdb.toArray().forEach(function(doc) {
var c = _.extend({}, doc), i, j, changed = false;
var c = Object.assign({}, doc), i, j, changed = false;
if (c.edgeDefinitions) {
for (i = 0; i < c.edgeDefinitions.length; ++i) {
var def = c.edgeDefinitions[i];

View File

@ -58,7 +58,7 @@ exports.union = function union() {
result = Array.prototype.concat.apply([], things);
} else {
things.unshift({});
result = _.extend.apply(_, things);
result = Object.assign(...things);
}
return result;
};

View File

@ -29,7 +29,6 @@
var internal = require("internal");
var fs = require("fs");
var console = require("console");
var _ = require('lodash');
var JSHINT = require("jshint").JSHINT;
var jshintrc = {};
@ -57,7 +56,7 @@ function RunTest(path, options) {
var result = {};
content = content.replace("/*jslint", "/*xxxxxx");
result["passed"] = JSHINT(content, _.extend({}, jshintrc, options));
result["passed"] = JSHINT(content, Object.assign({}, jshintrc, options));
if (JSHINT.errors) {
result["errors"] = JSHINT.errors;

View File

@ -40,7 +40,6 @@ var fs = require("fs");
var util = require("util");
var mimeTypes = require("mime-types");
var console = require("console");
var _ = require("lodash");
var arangodb = require("@arangodb");
var foxxManager = require("@arangodb/foxx/manager");
@ -888,7 +887,7 @@ function flattenRouting (routes, path, rexpr, urlParameters, depth, prefix) {
routes.exact[k],
path + "/" + k,
rexpr + "/" + k.replace(/([\.\+\*\?\^\$\(\)\[\]])/g, "\\$1"),
_.clone(urlParameters),
Object.assign({}, urlParameters),
depth + 1,
false));
}
@ -925,7 +924,7 @@ function flattenRouting (routes, path, rexpr, urlParameters, depth, prefix) {
cur = rexpr + match;
}
newUrlParameters = _.clone(urlParameters);
newUrlParameters = Object.assign({}, urlParameters);
newUrlParameters[parameter.parameter] = depth;
result = result.concat(flattenRouting(
@ -943,9 +942,9 @@ function flattenRouting (routes, path, rexpr, urlParameters, depth, prefix) {
// .............................................................................
if (routes.hasOwnProperty('routes')) {
var sorted = _.clone(routes.routes.sort(function(a,b) {
var sorted = [...routes.routes.sort(function(a,b) {
return b.priority - a.priority;
}));
})];
for (i = 0; i < sorted.length; ++i) {
sorted[i] = {
@ -1080,8 +1079,8 @@ function buildRouting (dbname) {
while (i.hasNext()) {
var n = i.next();
var c = _.extend({}, n);
var c = Object.assign({}, n);
c.name = '_routing.document("' + c._key + '")';
routes.push(c);

View File

@ -758,7 +758,7 @@ exports.Communication = function() {
diff.missing.push(toAdd);
return;
}
var compTo = _.extend({}, inferior[k]);
var compTo = Object.assign({}, inferior[k]);
delete compTo.address;
if (JSON.stringify(v) !== JSON.stringify(compTo)) {
diff.difference[k] = {};

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -243,8 +243,8 @@ function BaseMiddleware() {
actions.stringifyRequest(request));
}
_.extend(request, requestFunctions);
_.extend(response, responseFunctions);
Object.assign(request, requestFunctions);
Object.assign(response, responseFunctions);
next();

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -25,7 +26,6 @@
const RequestContext = require('@arangodb/foxx/legacy/request_context');
const BaseMiddleware = require('@arangodb/foxx/legacy/base_middleware').BaseMiddleware;
const _ = require('lodash');
const is = require('@arangodb/is');
const internal = require('@arangodb/foxx/legacy/internals');
const swagger = require('@arangodb/foxx/legacy/swagger');
@ -184,7 +184,7 @@ class Controller {
addInjector(name, factory) {
if (factory === undefined) {
_.extend(this.injectors, name);
Object.assign(this.injectors, name);
} else {
this.injectors[name] = factory;
}
@ -344,7 +344,7 @@ class Controller {
////////////////////////////////////////////////////////////////////////////////
activateAuthentication(opts) {
var authentication = require('@arangodb/foxx/legacy/authentication');
_.extend(this, authControllerProps);
Object.assign(this, authControllerProps);
this.auth = authentication.createAuthObject(this.applicationContext, opts);
this.before('/*', authentication.createAuthenticationMiddleware(this.auth, this.applicationContext));
@ -357,7 +357,7 @@ class Controller {
activateSessions(opts) {
var sessions = require('@arangodb/foxx/legacy/sessions');
_.extend(this, sessionControllerProps);
Object.assign(this, sessionControllerProps);
this.sessions = new sessions.Sessions(opts);
sessions.decorateController(this.sessions, this);

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -92,7 +93,7 @@ function Model(attributes) {
}
Model.prototype = Object.create(EventEmitter.prototype);
_.extend(Model.prototype, {
Object.assign(Model.prototype, {
////////////////////////////////////////////////////////////////////////////////
/// @brief was docuBlock JSF_foxx_model_get

View File

@ -81,7 +81,7 @@ exports.createQuery = function createQuery (cfg) {
} else {
vars = args.shift();
}
vars = _.extend({}, defaults, vars);
vars = Object.assign({}, defaults, vars);
if (context) {
_.each(vars, function (value, key) {
if (key.charAt(0) === '@') {

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -94,7 +95,7 @@ function Repository(collection, opts) {
Repository.prototype = Object.create(EventEmitter.prototype);
_.extend(Repository.prototype, {
Object.assign(Repository.prototype, {
// -----------------------------------------------------------------------------
// --SUBSECTION-- Adding Entries

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -323,7 +324,7 @@ class RequestContext {
cfg.options = [cfg.options];
}
_.each(cfg.options, function (options) {
_.extend(validateOptions, options);
Object.assign(validateOptions, options);
});
}
construct = function (raw) {
@ -425,7 +426,7 @@ class RequestContextBuffer {
}
}
_.extend(RequestContextBuffer.prototype, {
Object.assign(RequestContextBuffer.prototype, {
applyEachFunction(target) {
_.each(this.applyChain, function (x) {
target[x.functionName].apply(target, x.argumentList);
@ -459,7 +460,7 @@ _.each([
////////////////////////////////////////////////////////////////////////////////
'onlyIfAuthenticated'
], function (functionName) {
_.extend(RequestContextBuffer.prototype[functionName] = function () {
Object.assign(RequestContextBuffer.prototype[functionName] = function () {
this.applyChain.push({
functionName: functionName,
argumentList: arguments

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -321,7 +322,7 @@ function mountController(service, mount, filename) {
var foxx = foxxes[i];
var ri = foxx.routingInfo;
_.extend(service.routes.models, foxx.models);
Object.assign(service.routes.models, foxx.models);
if (ri.middleware) {
createMiddlewareMatchers(ri.middleware, service.routes, mount, ri.urlPrefix);

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -90,12 +90,12 @@ function TemplateMiddleware(templateCollection, helper) {
throw new Error("Unknown template language '" + template.templateLanguage + "'");
}
this.body = _.template(template.content)(_.extend(data, helper));
this.body = _.template(template.content)(Object.assign(data, helper));
this.contentType = template.contentType;
}
};
_.extend(response, responseFunctions);
Object.assign(response, responseFunctions);
};
if (_.isString(templateCollection)) {

View File

@ -236,7 +236,7 @@ function refillCaches(dbname) {
while (cursor.hasNext()) {
var config = cursor.next();
var app = new FoxxService(_.extend({}, config));
var app = new FoxxService(Object.assign({}, config));
var mount = app.mount;
cache[mount] = app;
routes.push(mount);
@ -840,7 +840,7 @@ function _scanFoxx(mount, options, activateDevelopment) {
if (old === null) {
throw new Error(`Could not find app for mountpoint "${mount}"`);
}
var data = _.extend({}, old);
var data = Object.assign({}, old);
data.manifest = app.toJSON().manifest;
utils.getStorage().replace(old, data);
}
@ -884,7 +884,7 @@ function rescanFoxx(mount) {
initCache();
_scanFoxx(
mount,
_.extend({}, old.options, {replace: true}),
Object.assign({}, old.options, {replace: true}),
old.isDevelopment
);
}

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,5 +1,6 @@
/*eslint camelcase:false */
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -22,7 +23,6 @@
/// @author Alan Plum
////////////////////////////////////////////////////////////////////////////////
const _ = require('lodash');
const url = require('url');
const parseUrl = url.parse;
const formatUrl = url.format;
@ -43,7 +43,7 @@ function parse(str) {
module.exports = function oauth2(cfg) {
function getTokenRequest(code, redirect_uri) {
const endpoint = parseUrl(cfg.tokenEndpoint);
const body = _.extend(
const body = Object.assign(
{grant_type: 'authorization_code'},
parseQuery(endpoint.query),
{
@ -63,7 +63,7 @@ module.exports = function oauth2(cfg) {
function getActiveUserUrl(access_token) {
const endpoint = parseUrl(cfg.activeUserEndpoint);
delete endpoint.search;
endpoint.query = _.extend(
endpoint.query = Object.assign(
parseQuery(endpoint.query),
{access_token}
);
@ -78,7 +78,7 @@ module.exports = function oauth2(cfg) {
}
const endpoint = parseUrl(cfg.authEndpoint);
delete endpoint.search;
endpoint.query = _.extend(
endpoint.query = Object.assign(
{response_type: 'code'},
parseQuery(endpoint.query),
opts,

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -42,7 +43,7 @@ function validate(data, schema) {
}));
if (isTuple) {
raw = Array.isArray(raw) ? raw : [raw];
data = _.extend({}, raw);
data = Object.assign({}, raw);
}
var result = schema.validate(data);
if (result.error) {
@ -182,7 +183,7 @@ function Job(id) {
}, this);
}
_.extend(Job.prototype, {
Object.assign(Job.prototype, {
abort: function () {
var self = this;
db._executeTransaction({
@ -231,13 +232,13 @@ function asNumber(num) {
return num ? Number(num) : 0;
}
_.extend(Queue.prototype, {
Object.assign(Queue.prototype, {
push: function (type, data, opts) {
if (!type) {
throw new Error('Must pass a job type!');
}
type = _.extend({}, type);
type = Object.assign({}, type);
if (type.schema) {
data = validate(data, type.schema);

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -22,7 +23,6 @@
/// @author Alan Plum
////////////////////////////////////////////////////////////////////////////////
var _ = require('lodash');
var tasks = require('@arangodb/tasks');
var db = require('@arangodb').db;
var qb = require('aqb');
@ -85,7 +85,7 @@ var runInDatabase = function () {
offset: 1,
isSystem: true,
params: {
job: _.extend({}, job, {status: 'progress'}),
job: Object.assign({}, job, {status: 'progress'}),
db: db._name()
}
});

View File

@ -1,5 +1,6 @@
/*jshint evil: true */
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -23,7 +24,6 @@
/// @author Alan Plum
////////////////////////////////////////////////////////////////////////////////
var _ = require('lodash');
var db = require('@arangodb').db;
var flatten = require('internal').flatten;
var exponentialBackOff = require('internal').exponentialBackOff;
@ -153,7 +153,7 @@ exports.work = function (job) {
data.runFailures = 0;
}
db._jobs.update(job._key, data);
job = _.extend(job, data);
job = Object.assign(job, data);
}
});

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -21,7 +22,6 @@
/// @author Alan Plum
////////////////////////////////////////////////////////////////////////////////
const _ = require('lodash');
const joi = require('joi');
const DEFAULT_PARAM_SCHEMA = joi.string().required();
@ -45,7 +45,7 @@ function reverse(pathTokens, pathParamNames) {
return '/' + path.join('/');
}
module.exports = _.extend(
module.exports = Object.assign(
function tokenize(path, ctx) {
if (path === '/') {
return [$_TERMINAL];

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -212,7 +213,7 @@ function applyPathParams(route) {
function dispatch(route, req, res) {
const ignoreRequestBody = actions.BODYFREE_METHODS.indexOf(req.method) !== -1;
let pathParams = {};
let queryParams = _.clone(req.queryParams);
let queryParams = Object.assign({}, req.queryParams);
{
let basePath = [];
@ -309,7 +310,7 @@ function dispatch(route, req, res) {
throw new Error(`Route could not be resolved: "${routeName}"`);
}
params = _.extend({}, params);
params = Object.assign({}, params);
const parts = [];
for (const item of reversedRoute) {
const context = item.router || item.endpoint || item.middleware;
@ -354,13 +355,13 @@ function dispatch(route, req, res) {
};
if (item.endpoint || item.router) {
pathParams = _.extend(pathParams, item.pathParams);
queryParams = _.extend(queryParams, item.queryParams);
pathParams = Object.assign(pathParams, item.pathParams);
queryParams = Object.assign(queryParams, item.queryParams);
req.pathParams = pathParams;
req.queryParams = queryParams;
} else {
req.pathParams = _.extend(_.clone(pathParams), item.pathParams);
req.queryParams = _.extend(_.clone(queryParams), item.queryParams);
req.pathParams = Object.assign({}, pathParams, item.pathParams);
req.queryParams = Object.assign({}, queryParams, item.queryParams);
}
if (!context._handler) {

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
@ -312,7 +313,7 @@ module.exports = class FoxxService {
const options = this.options.configuration;
_.each(definitions, function (dfn, name) {
const value = options[name] === undefined ? dfn.default : options[name];
config[name] = simple ? value : _.extend({}, dfn, {
config[name] = simple ? value : Object.assign({}, dfn, {
title: getReadableName(name),
current: value
});
@ -350,7 +351,7 @@ module.exports = class FoxxService {
const module = new Module(filename, this.main);
module[$_MODULE_CONTEXT].console = this.main[$_MODULE_CONTEXT].console;
module.context = _.extend(
module.context = Object.assign(
new FoxxContext(this),
this.main.context,
options.foxxContext

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -44,19 +44,20 @@ module.exports = function systemStorage(cfg) {
},
fromClient(sid) {
try {
const now = Date.now();
const doc = db._sessions.document(sid);
const internalAccessTime = internal.accessSid(sid);
if (internalAccessTime) {
doc.lastAccess = internalAccessTime;
}
if ((doc.lastAccess + expiry) < Date.now()) {
if ((doc.lastAccess + expiry) < now) {
this.clear(sid);
return null;
}
db._sessions.update(sid, {lastAccess: now});
return {
_key: doc._key,
uid: doc.uid,
userData: doc.userData,
created: doc.created,
data: doc.sessionData
};
@ -77,7 +78,6 @@ module.exports = function systemStorage(cfg) {
const uid = session.uid;
const payload = {
uid: uid || null,
userData: session.userData || {},
sessionData: session.data || {},
created: session.created || Date.now(),
lastAccess: Date.now(),
@ -105,13 +105,11 @@ module.exports = function systemStorage(cfg) {
setUser(session, user) {
if (user) {
session.uid = user._key;
session.userData = user.userData;
if (session._key) {
internal.createSid(session._key, user.user);
}
} else {
session.uid = null;
session.userData = {};
if (session._key) {
internal.clearSid(session._key);
}
@ -136,7 +134,6 @@ module.exports = function systemStorage(cfg) {
new() {
return {
uid: null,
userData: {},
created: Date.now(),
data: {}
};

View File

@ -36,6 +36,7 @@ module.exports = function collectionStorage(cfg) {
if (!cfg) {
cfg = {};
}
const autoUpdate = Boolean(cfg.autoUpdate);
const pruneExpired = Boolean(cfg.pruneExpired);
const expiry = (cfg.expiry || 60) * 60 * 1000;
const collection = (
@ -56,13 +57,17 @@ module.exports = function collectionStorage(cfg) {
},
fromClient(sid) {
try {
const now = Date.now();
const session = collection.document(sid);
if (session.expires < Date.now()) {
if (session.expires < now) {
if (pruneExpired) {
collection.remove(session);
}
return null;
}
if (autoUpdate) {
collection.update(sid, {expires: now + expiry});
}
return {
_key: session._key,
uid: session.uid,

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,5 +1,4 @@
'use strict';
const _ = require('lodash');
const dd = require('dedent');
const joi = require('joi');
const httpError = require('http-errors');
@ -43,7 +42,7 @@ router.post(function (req, res) {
}
throw e;
}
_.extend(<%= document %>, meta);
Object.assign(<%= document %>, meta);
res.status(201);
res.set('location', req.makeAbsolute(
req.reverse('detail', {key: <%= document %>._key})
@ -96,7 +95,7 @@ router.put(':key', function (req, res) {
}
throw e;
}
_.extend(<%= document %>, meta);
Object.assign(<%= document %>, meta);
res.send(<%= document %>);
}, 'replace')
.pathParam('key', keySchema)

View File

@ -1,5 +1,4 @@
'use strict';
const _ = require('lodash');
const dd = require('dedent');
const joi = require('joi');
const httpError = require('http-errors');
@ -21,8 +20,8 @@ const HTTP_CONFLICT = status('conflict');
const router = createRouter();
module.exports = router;
const New<%= model %> = _.extend({}, <%= model %>, {
schema: _.extend({}, <%= model %>.schema, {
const New<%= model %> = Object.assign({}, <%= model %>, {
schema: Object.assign({}, <%= model %>.schema, {
_from: joi.string(),
_to: joi.string()
})
@ -50,7 +49,7 @@ router.post(function (req, res) {
}
throw e;
}
_.extend(<%= document %>, meta);
Object.assign(<%= document %>, meta);
res.status(201);
res.set('location', req.makeAbsolute(
req.reverse('detail', {key: <%= document %>._key})
@ -103,7 +102,7 @@ router.put(':key', function (req, res) {
}
throw e;
}
_.extend(<%= document %>, meta);
Object.assign(<%= document %>, meta);
res.send(<%= document %>);
}, 'replace')
.pathParam('key', keySchema)

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -1,4 +1,5 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///

View File

@ -56,7 +56,7 @@ FunctionStub = function(obj) {
this.obj = obj;
};
_.extend(FunctionStub.prototype, {
Object.assign(FunctionStub.prototype, {
toReceive: function (functionName) {
'use strict';
this.functionName = functionName;