fix: undef file

This commit is contained in:
diced 2023-03-04 17:51:40 -08:00
parent ac05d82e3a
commit 4912a872e0
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1

View file

@ -49,10 +49,10 @@ async function handler(req: NextApiReq, res: NextApiRes, user: UserExtended) {
} else if (req.method === 'PATCH') { } else if (req.method === 'PATCH') {
if (!req.body.id) return res.badRequest('no file id'); if (!req.body.id) return res.badRequest('no file id');
let image; let file;
if (req.body.favorite !== null) if (req.body.favorite !== null)
image = await prisma.file.update({ file = await prisma.file.update({
where: { id: req.body.id }, where: { id: req.body.id },
data: { data: {
favorite: req.body.favorite, favorite: req.body.favorite,
@ -61,7 +61,7 @@ async function handler(req: NextApiReq, res: NextApiRes, user: UserExtended) {
// @ts-ignore // @ts-ignore
if (file.password) file.password = true; if (file.password) file.password = true;
return res.json(image); return res.json(file);
} else { } else {
if (req.query.count) { if (req.query.count) {
const count = await prisma.file.count({ const count = await prisma.file.count({