feat(api): add rate-limiting and /clear-guild-cache (#198)

This commit is contained in:
41666 2021-03-23 22:14:33 -04:00 committed by GitHub
parent 57d83699d5
commit a4fd37d71c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 138 additions and 12 deletions

View file

@ -171,10 +171,23 @@ const rebuild = () =>
const watcher = chokidar.watch(path.resolve(__dirname, basePath), {
ignoreInitial: true,
ignore: '**/{dist,node_modules}',
ignore: '**/dist',
});
let currentlyRebuilding = false;
watcher.on('all', async (type, path) => {
if (path.includes('node_modules') || path.includes('dist')) {
return;
}
if (currentlyRebuilding) {
console.info('change skipped...', { type, path });
return;
}
currentlyRebuilding = true;
if (path.includes('dist')) {
return;
}
@ -183,6 +196,8 @@ watcher.on('all', async (type, path) => {
await rebuild();
reload();
currentlyRebuilding = false;
});
fork(async () => {