chore: vsc autoformat

pull/242/head
Josh Moore 1 year ago
parent 6927bbdc26
commit 3709a6958e

@ -2,7 +2,6 @@ import { UserConfiguration, UserConfigTypeChecker } from 'ass';
import fs from 'fs-extra'; import fs from 'fs-extra';
import { path } from '@tycrek/joint'; import { path } from '@tycrek/joint';
import { log } from './log'; import { log } from './log';
const FILEPATH = path.join('.ass-data/userconfig.json'); const FILEPATH = path.join('.ass-data/userconfig.json');

@ -21,11 +21,11 @@ export const rateLimiterMiddleware = (group: string, config: EndpointRateLimitCo
return rateLimiterGroups.get(group)!; return rateLimiterGroups.get(group)!;
} else { } else {
rateLimiterGroups.set(group, rateLimit({ rateLimiterGroups.set(group, rateLimit({
limit: config.requests, limit: config.requests,
windowMs: config.duration * 1000, windowMs: config.duration * 1000,
skipFailedRequests: true, skipFailedRequests: true,
legacyHeaders: false, legacyHeaders: false,
standardHeaders: "draft-7", standardHeaders: 'draft-7',
keyGenerator: (req, res) => { keyGenerator: (req, res) => {
return req.ip || 'disconnected'; return req.ip || 'disconnected';
}, },

@ -39,7 +39,7 @@ router.post('/setup', BodyParserJson(), async (req, res) => {
}); });
// User login // User login
router.post('/login', rateLimiterMiddleware("login", UserConfig.config.rateLimit?.login), BodyParserJson(), (req, res) => { router.post('/login', rateLimiterMiddleware('login', UserConfig.config.rateLimit?.login), BodyParserJson(), (req, res) => {
const { username, password } = req.body; const { username, password } = req.body;
data.getAll('users') data.getAll('users')
@ -69,7 +69,7 @@ router.post('/login', rateLimiterMiddleware("login", UserConfig.config.rateLimit
}); });
// todo: authenticate API endpoints // todo: authenticate API endpoints
router.post('/user', rateLimiterMiddleware("api", UserConfig.config.rateLimit?.api), BodyParserJson(), async (req, res) => { router.post('/user', rateLimiterMiddleware('api', UserConfig.config.rateLimit?.api), BodyParserJson(), async (req, res) => {
if (!UserConfig.ready) if (!UserConfig.ready)
return res.status(409).json({ success: false, message: 'User config not ready' }); return res.status(409).json({ success: false, message: 'User config not ready' });

2
common/types.d.ts vendored

@ -59,7 +59,7 @@ declare module 'ass' {
database: string; database: string;
} }
} }
/** /**
* rate limiter configuration * rate limiter configuration
* @since 0.15.0 * @since 0.15.0

@ -55,7 +55,7 @@ document.addEventListener('DOMContentLoaded', () => {
ratelimitApiTime: document.querySelector('#ratelimit-api-time') as SlInput, ratelimitApiTime: document.querySelector('#ratelimit-api-time') as SlInput,
ratelimitUploadRequests: document.querySelector('#ratelimit-upload-requests') as SlInput, ratelimitUploadRequests: document.querySelector('#ratelimit-upload-requests') as SlInput,
ratelimitUploadTime: document.querySelector('#ratelimit-upload-time') as SlInput, ratelimitUploadTime: document.querySelector('#ratelimit-upload-time') as SlInput,
submitButton: document.querySelector('#submit') as SlButton, submitButton: document.querySelector('#submit') as SlButton,
}; };
@ -101,7 +101,7 @@ document.addEventListener('DOMContentLoaded', () => {
// append rate limit config, if specified // append rate limit config, if specified
if (( if ((
Elements.ratelimitLoginRequests.value Elements.ratelimitLoginRequests.value
|| Elements.ratelimitLoginTime.value || Elements.ratelimitLoginTime.value
|| Elements.ratelimitUploadRequests.value || Elements.ratelimitUploadRequests.value
|| Elements.ratelimitUploadTime.value || Elements.ratelimitUploadTime.value
@ -110,11 +110,11 @@ document.addEventListener('DOMContentLoaded', () => {
) { ) {
if (!config.rateLimit) config.rateLimit = {}; if (!config.rateLimit) config.rateLimit = {};
if ( if (
genericRateLimit(config.rateLimit, 'login', Elements.submitButton, Elements.ratelimitLoginRequests, Elements.ratelimitLoginTime) genericRateLimit(config.rateLimit, 'login', Elements.submitButton, Elements.ratelimitLoginRequests, Elements.ratelimitLoginTime)
|| genericRateLimit(config.rateLimit, 'api', Elements.submitButton, Elements.ratelimitApiRequests, Elements.ratelimitApiTime) || genericRateLimit(config.rateLimit, 'api', Elements.submitButton, Elements.ratelimitApiRequests, Elements.ratelimitApiTime)
|| genericRateLimit(config.rateLimit, 'upload', Elements.submitButton, Elements.ratelimitUploadRequests, Elements.ratelimitUploadTime) || genericRateLimit(config.rateLimit, 'upload', Elements.submitButton, Elements.ratelimitUploadRequests, Elements.ratelimitUploadTime)
) { ) {
return; return;
} }
} }

Loading…
Cancel
Save