Skip to content

Commit 6f8b0d3

Browse files
committed
chore: fix linting errors
1 parent 103140b commit 6f8b0d3

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
2929
"release:patch": "yarn lint && yarn test && yarn prepack && changelogen --release --patch && yarn publish && git push --follow-tags",
3030
"release:minor": "yarn lint && yarn test && yarn prepack && changelogen --release --minor && yarn publish && git push --follow-tags",
31-
"lint": "eslint .",
31+
"lint:fix": "eslint . --fix",
3232
"test": "vitest run --testTimeout 15000 --reporter=basic --disable-console-intercept",
3333
"test:watch": "vitest watch --testTimeout 15000 --reporter=basic --disable-console-intercept"
3434
},
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
1-
import type { RateLimit } from '#imports'; // Assuming RateLimit type is made available via #imports
2-
import { useRuntimeConfig } from '#imports';
1+
import type { RateLimit } from '#imports' // Assuming RateLimit type is made available via #imports
2+
import { useRuntimeConfig } from '#imports'
33

44
export default defineTask({
55
meta: {
66
name: 'shield:cleanIpData',
77
description: 'Clean old IP tracking data from nuxt-api-shield storage.',
88
},
99
async run() {
10-
const shieldStorage = useStorage('shield');
11-
const config = useRuntimeConfig().public.nuxtApiShield;
10+
const shieldStorage = useStorage('shield')
11+
const config = useRuntimeConfig().public.nuxtApiShield
1212

1313
// ipTTL is expected to be in seconds from config, module applies default if not set by user
14-
const ipTTLseconds = config.ipTTL;
14+
const ipTTLseconds = config.ipTTL
1515

1616
if (!ipTTLseconds || ipTTLseconds <= 0) {
17-
console.log('[nuxt-api-shield] IP data cleanup (ipTTL) is disabled or invalid.');
18-
return { result: { cleanedCount: 0, status: 'disabled_or_invalid_ttl' } };
17+
console.log('[nuxt-api-shield] IP data cleanup (ipTTL) is disabled or invalid.')
18+
return { result: { cleanedCount: 0, status: 'disabled_or_invalid_ttl' } }
1919
}
20-
const ipTTLms = ipTTLseconds * 1000;
20+
const ipTTLms = ipTTLseconds * 1000
2121

22-
const ipKeys = await shieldStorage.getKeys('ip:');
23-
const currentTime = Date.now();
24-
let cleanedCount = 0;
22+
const ipKeys = await shieldStorage.getKeys('ip:')
23+
const currentTime = Date.now()
24+
let cleanedCount = 0
2525

2626
for (const key of ipKeys) {
27-
const entry = await shieldStorage.getItem(key) as RateLimit | null;
27+
const entry = await shieldStorage.getItem(key) as RateLimit | null
2828

2929
if (entry && typeof entry.time === 'number') {
3030
if ((currentTime - entry.time) > ipTTLms) {
31-
await shieldStorage.removeItem(key);
32-
cleanedCount++;
31+
await shieldStorage.removeItem(key)
32+
cleanedCount++
3333
}
34-
} else {
34+
}
35+
else {
3536
// Clean up potentially malformed (not RateLimit object), null, or missing 'time' property entries
36-
await shieldStorage.removeItem(key);
37-
cleanedCount++;
37+
await shieldStorage.removeItem(key)
38+
cleanedCount++
3839
}
3940
}
4041

41-
console.log(`[nuxt-api-shield] Cleaned ${cleanedCount} old/malformed IP data entries.`);
42-
return { result: { cleanedCount } };
42+
console.log(`[nuxt-api-shield] Cleaned ${cleanedCount} old/malformed IP data entries.`)
43+
return { result: { cleanedCount } }
4344
},
44-
});
45+
})

src/runtime/server/utils/isActualBanTimestampExpired.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
export const isActualBanTimestampExpired = (bannedUntilRaw: unknown): boolean => {
77
if (bannedUntilRaw === null || bannedUntilRaw === undefined) {
88
// Consider null/undefined entries as invalid/expired for cleanup
9-
return true;
9+
return true
1010
}
11-
const numericTimestamp = Number(bannedUntilRaw);
11+
const numericTimestamp = Number(bannedUntilRaw)
1212
if (Number.isNaN(numericTimestamp)) {
1313
// Malformed data, treat as expired for cleanup
14-
return true;
14+
return true
1515
}
1616
// Ban is expired if current time is greater than or equal to the stored timestamp
17-
return Date.now() >= numericTimestamp;
18-
};
17+
return Date.now() >= numericTimestamp
18+
}

0 commit comments

Comments
 (0)