mirror of https://gitee.com/bigwinds/arangodb
let -> const
This commit is contained in:
parent
f758c4764e
commit
d51a8bd1d6
|
@ -388,43 +388,42 @@ function dispatch(route, req, res) {
|
||||||
|
|
||||||
|
|
||||||
function* findRoutes(node, result, suffix, path) {
|
function* findRoutes(node, result, suffix, path) {
|
||||||
let wildcardNode = node.get(tokenize.WILDCARD);
|
const wildcardNode = node.get(tokenize.WILDCARD);
|
||||||
let nodeMiddleware = [];
|
|
||||||
|
|
||||||
if (wildcardNode && wildcardNode.has($_MIDDLEWARE)) {
|
if (wildcardNode && wildcardNode.has($_MIDDLEWARE)) {
|
||||||
nodeMiddleware = wildcardNode.get($_MIDDLEWARE);
|
const nodeMiddleware = wildcardNode.get($_MIDDLEWARE);
|
||||||
result = result.concat(nodeMiddleware.map(
|
result = result.concat(nodeMiddleware.map(
|
||||||
(mw) => ({middleware: mw, path: path, suffix: suffix})
|
(mw) => ({middleware: mw, path: path, suffix: suffix})
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!suffix.length) {
|
if (!suffix.length) {
|
||||||
let terminalNode = node.get(tokenize.TERMINAL);
|
const terminalNode = node.get(tokenize.TERMINAL);
|
||||||
let terminalRoutes = terminalNode && terminalNode.get($_ROUTES) || [];
|
const terminalRoutes = terminalNode && terminalNode.get($_ROUTES) || [];
|
||||||
for (let endpoint of terminalRoutes) {
|
for (const endpoint of terminalRoutes) {
|
||||||
yield result.concat(
|
yield result.concat(
|
||||||
{endpoint: endpoint, path: path, suffix: suffix}
|
{endpoint: endpoint, path: path, suffix: suffix}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let part = suffix[0];
|
const part = suffix[0];
|
||||||
let path2 = path.concat(part);
|
const path2 = path.concat(part);
|
||||||
let suffix2 = suffix.slice(1);
|
const suffix2 = suffix.slice(1);
|
||||||
for (let childNode of [node.get(part), node.get(tokenize.PARAM)]) {
|
for (const childNode of [node.get(part), node.get(tokenize.PARAM)]) {
|
||||||
if (childNode) {
|
if (childNode) {
|
||||||
yield* findRoutes(childNode, result, suffix2, path2);
|
yield* findRoutes(childNode, result, suffix2, path2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let wildcardRoutes = wildcardNode && wildcardNode.get($_ROUTES) || [];
|
const wildcardRoutes = wildcardNode && wildcardNode.get($_ROUTES) || [];
|
||||||
for (let endpoint of wildcardRoutes) {
|
for (const endpoint of wildcardRoutes) {
|
||||||
if (endpoint.router) {
|
if (endpoint.router) {
|
||||||
let childNode = endpoint.tree.root;
|
const childNode = endpoint.tree.root;
|
||||||
let result2 = result.concat(
|
const result2 = result.concat(
|
||||||
{router: endpoint, path: path, suffix: suffix}
|
{router: endpoint, path: path, suffix: suffix}
|
||||||
);
|
);
|
||||||
let path2 = [];
|
const path2 = [];
|
||||||
yield* findRoutes(childNode, result2, suffix, path2);
|
yield* findRoutes(childNode, result2, suffix, path2);
|
||||||
} else {
|
} else {
|
||||||
yield result.concat(
|
yield result.concat(
|
||||||
|
@ -437,10 +436,10 @@ function* findRoutes(node, result, suffix, path) {
|
||||||
|
|
||||||
function* flatten(node, result) {
|
function* flatten(node, result) {
|
||||||
for (let entry of node.entries()) {
|
for (let entry of node.entries()) {
|
||||||
let token = entry[0];
|
const token = entry[0];
|
||||||
let child = entry[1];
|
const child = entry[1];
|
||||||
if (token === tokenize.WILDCARD || token === tokenize.TERMINAL) {
|
if (token === tokenize.WILDCARD || token === tokenize.TERMINAL) {
|
||||||
for (let endpoint of child.get($_ROUTES) || []) {
|
for (const endpoint of child.get($_ROUTES) || []) {
|
||||||
if (endpoint.router) {
|
if (endpoint.router) {
|
||||||
yield* flatten(endpoint.tree.root, result.concat(endpoint));
|
yield* flatten(endpoint.tree.root, result.concat(endpoint));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue