Skip to content

Commit 012a01a

Browse files
authored
chore: fixes code smells (#46)
1 parent 10b5988 commit 012a01a

File tree

18 files changed

+388
-440
lines changed

18 files changed

+388
-440
lines changed

npm-shrinkwrap.json

Lines changed: 355 additions & 403 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@
5050
"jsonwebtoken": "^9.0.2",
5151
"moment": "^2.30.1",
5252
"mongodb": "^6.20.0",
53-
"mongoose": "^8.18.2",
54-
"pino": "^9.11.0",
53+
"mongoose": "^8.19.0",
54+
"pino": "^10.0.0",
5555
"pino-pretty": "^13.1.1",
5656
"swagger-ui-express": "^5.0.1",
5757
"switcher-client": "^4.4.1",
5858
"validator": "^13.15.15"
5959
},
6060
"devDependencies": {
6161
"env-cmd": "^11.0.0",
62-
"eslint": "^9.36.0",
63-
"jest": "^30.1.3",
62+
"eslint": "^9.37.0",
63+
"jest": "^30.2.0",
6464
"jest-sonar-reporter": "^2.0.0",
6565
"node-notifier": "^10.0.1",
6666
"nodemon": "^3.1.10",

src/aggregator/resolvers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ export const resolveConfigByKey = async (domain, key) => Config.findOne({ domain
1414
export function resolveEnvValue(source, field, keys) {
1515
const arrValue = [];
1616

17-
keys.forEach(k => {
17+
for (const k of keys) {
1818
arrValue.push({
1919
env: k,
2020
value: source[field][k]
2121
});
22-
});
22+
}
2323

2424
return arrValue;
2525
}

src/app-server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import https from 'https';
2-
import http from 'http';
3-
import fs from 'fs';
1+
import https from 'node:https';
2+
import http from 'node:http';
3+
import fs from 'node:fs';
44
import Logger from './helpers/logger.js';
55

66
export const createServer = (app) => {

src/external/switcher-api-facade.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function getRateLimit(key, component) {
4040
}
4141
}
4242

43-
return parseInt(process.env.MAX_REQUEST_PER_MINUTE || DEFAULT_RATE_LIMIT);
43+
return Number.parseInt(process.env.MAX_REQUEST_PER_MINUTE || DEFAULT_RATE_LIMIT);
4444
}
4545

4646
export async function checkHttpsAgent(value) {

src/helpers/cache/worker-manager.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ export const STATUS_TYPE = {
2828
};
2929

3030
export class CacheWorkerManager {
31-
DEFAULT_INTERVAL = 5000;
31+
#DEFAULT_INTERVAL = 5000;
32+
worker = null;
3233

3334
constructor(eventHandlers, options) {
34-
this.worker = null;
3535
this.status = STATUS_TYPE.STOPPED;
3636
this.onCacheUpdates = eventHandlers.onCacheUpdates;
3737
this.onCacheDeletions = eventHandlers.onCacheDeletions;
@@ -40,7 +40,7 @@ export class CacheWorkerManager {
4040
this.onError = eventHandlers.onError;
4141

4242
this.options = {
43-
interval: this.DEFAULT_INTERVAL,
43+
interval: this.#DEFAULT_INTERVAL,
4444
...options
4545
};
4646
}

src/helpers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function payloadReader(payload) {
99
return Object.keys(payloadRead)
1010
.flatMap(field => [field, ...payloadReader(payload[field])
1111
.map(nestedField => `${field}.${nestedField}`)])
12-
.filter(field => isNaN(Number(field)))
12+
.filter(field => Number.isNaN(Number(field)))
1313
.reduce((acc, curr) => {
1414
if (!acc.includes(curr)) {
1515
acc.push(curr);

src/helpers/ipcidr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default class IPCIDR {
44
}
55

66
ip4ToInt(ip) {
7-
return ip.split('.').reduce((int, oct) => (int << 8) + parseInt(oct, 10), 0) >>> 0;
7+
return ip.split('.').reduce((int, oct) => (int << 8) + Number.parseInt(oct, 10), 0) >>> 0;
88
}
99

1010
isIp4InCidr(ip) {

src/helpers/timed-match/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import cp from 'child_process';
2-
import path from 'path';
3-
import { fileURLToPath } from 'url';
1+
import cp from 'node:child_process';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
44

55
const __filename = fileURLToPath(import.meta.url);
66
const __dirname = path.dirname(__filename);

src/middleware/limiter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const ERROR_MESSAGE = {
77

88
const getMaxRate = (rate_limit) => {
99
if (rate_limit === 0) {
10-
return parseInt(DEFAULT_RATE_LIMIT);
10+
return Number.parseInt(DEFAULT_RATE_LIMIT);
1111
}
1212

1313
return rate_limit;
@@ -17,7 +17,7 @@ export const DEFAULT_RATE_LIMIT = 1000;
1717

1818
export const defaultLimiter = rateLimit({
1919
windowMs: DEFAULT_WINDOWMS,
20-
limit: getMaxRate(parseInt(process.env.MAX_REQUEST_PER_MINUTE)),
20+
limit: getMaxRate(Number.parseInt(process.env.MAX_REQUEST_PER_MINUTE)),
2121
standardHeaders: 'draft-7',
2222
legacyHeaders: false,
2323
message: ERROR_MESSAGE,

0 commit comments

Comments
 (0)