Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: preferred filter fix, Config.PREFERRED_NODES is empty by default #126

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"scripts": {
"dev": "nodemon",
"debug": "node --inspect-brk=0.0.0.0:9229 --require ts-node/register src/app.ts",
"build": "shx rm -rf ./dist/ && tsc && shx cp -r openapi dist/openapi",
"build:clients": "bash scripts/build-clients.sh",
"start": "node dist/app.js",
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"NUMBER_OF_NODE_REQUEST_CHUNK": 10,
"NODE_PEERS_REQUEST_CHUNK_SIZE": 50,
"CHAIN_HEIGHT_REQUEST_CHUNK_SIZE": 10,
"PREFERRED_NODES": ["*.symboldev.network"],
"PREFERRED_NODES": [],
"MIN_PARTNER_NODE_VERSION": 16777728
}
2 changes: 0 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export const verifyConfig = (cfg: Config): boolean => {
error = 'Invalid "NODES"';
}

if (cfg.symbol.PREFERRED_NODES.length === 0) error = 'Invalid "PREFERRED NODES"';

if (isNaN(cfg.monitor.NODE_MONITOR_SCHEDULE_INTERVAL) || cfg.monitor.NODE_MONITOR_SCHEDULE_INTERVAL < 0)
error = 'Invalid "NODE_MONITOR_SCHEDULE_INTERVAL"';

Expand Down
7 changes: 5 additions & 2 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ export class Routes {
}

// ?filter=preferred
// it filter by host / domain name config by admin.
// it filters by host / domain name config by admin.
if (filter === NodeFilter.Preferred) {
if (!symbol.PREFERRED_NODES?.length) {
return Promise.resolve(res.send([]));
}
Object.assign(searchCriteria.filter, {
host: { $in: symbol.PREFERRED_NODES.map((node) => new RegExp(`^.${node}`, 'i')) },
host: { $in: symbol.PREFERRED_NODES.map((node) => new RegExp(`^${node}`, 'i')) },
'apiStatus.isAvailable': true,
'apiStatus.nodeStatus.apiNode': 'up',
'apiStatus.nodeStatus.db': 'up',
Expand Down