weird error in production (TypeError: Right side of assignment cannot be destructured)

I just checked the logs from my production server and saw this error, several times and can't understand why they may be happening: I can't seem to reproduce it manually. Here's the code "causing" it: Any insights would be welcome.
import { db, eq, Variants } from 'pertentodb';

export const canVariant = async (req, res, next) => {
const variantId = req.params.variantId || req.body.variantId;
if (!variantId || isNaN(variantId)) return next();

const variant = await db.query.Variants.findFirst({
where: eq(Variants.id, variantId),
});

const { companyId, parentCompanyId } = variant;

if (![companyId, parentCompanyId].includes(req.user.companyId)) {
if (req.user.role !== 'Super Admin') {
return res.status(403).send('FORBIDDEN');
}
}

req.variant = variant;

return next();
};
import { db, eq, Variants } from 'pertentodb';

export const canVariant = async (req, res, next) => {
const variantId = req.params.variantId || req.body.variantId;
if (!variantId || isNaN(variantId)) return next();

const variant = await db.query.Variants.findFirst({
where: eq(Variants.id, variantId),
});

const { companyId, parentCompanyId } = variant;

if (![companyId, parentCompanyId].includes(req.user.companyId)) {
if (req.user.role !== 'Super Admin') {
return res.status(403).send('FORBIDDEN');
}
}

req.variant = variant;

return next();
};
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server