fix: max call stack error
This commit is contained in:
parent
725ce50608
commit
6d2d071293
4 changed files with 9 additions and 7 deletions
|
@ -3,7 +3,6 @@ import { expand } from 'dotenv-expand';
|
|||
import { existsSync, readFileSync } from 'fs';
|
||||
import Logger from '../logger';
|
||||
import { humanToBytes } from '../utils/bytes';
|
||||
import { parseExpiry } from '../utils/client';
|
||||
|
||||
export type ValueType = 'string' | 'number' | 'boolean' | 'array' | 'json-array' | 'human-to-byte';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { s } from '@sapphire/shapeshift';
|
||||
import { Config } from 'lib/config/Config';
|
||||
import type { Config } from './Config';
|
||||
import { inspect } from 'util';
|
||||
import Logger from '../logger';
|
||||
import { humanToBytes } from '../utils/bytes';
|
||||
|
|
|
@ -14,14 +14,14 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
},
|
||||
});
|
||||
|
||||
if (!image) return res.status(404).end(JSON.stringify({ error: 'Image not found' }));
|
||||
if (!password) return res.badRequest('No password provided');
|
||||
if (!image) return res.notFound('image not found');
|
||||
if (!password) return res.badRequest('no password provided');
|
||||
|
||||
const valid = await checkPassword(password as string, image.password);
|
||||
if (!valid) return res.badRequest('Wrong password');
|
||||
if (!valid) return res.badRequest('wrong password');
|
||||
|
||||
const data = await datasource.get(image.file);
|
||||
if (!data) return res.notFound('Image not found');
|
||||
if (!data) return res.notFound('image not found');
|
||||
|
||||
const size = await datasource.size(image.file);
|
||||
|
||||
|
@ -30,7 +30,7 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
res.setHeader('Content-Length', size);
|
||||
|
||||
data.pipe(res);
|
||||
data.on('error', () => res.error('Image not found'));
|
||||
data.on('error', () => res.notFound('image not found'));
|
||||
data.on('end', () => res.end());
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ async function handler(req: NextApiReq, res: NextApiRes, user: UserExtended) {
|
|||
}
|
||||
} else if (req.method === 'DELETE') {
|
||||
const { code } = req.query as { code: string };
|
||||
if (!code) return res.badRequest('no code');
|
||||
|
||||
const invite = await prisma.invite.delete({
|
||||
where: {
|
||||
|
@ -67,6 +68,8 @@ async function handler(req: NextApiReq, res: NextApiRes, user: UserExtended) {
|
|||
},
|
||||
});
|
||||
|
||||
if (!invite) return res.notFound('invite not found');
|
||||
|
||||
logger.debug(`deleted invite ${JSON.stringify(invite)}`);
|
||||
|
||||
logger.info(`${user.username} (${user.id}) deleted invite ${invite.code}`);
|
||||
|
|
Loading…
Reference in a new issue