in src/app.ts [39:72]
function handleImageSigning(
config: SignedImageUrlConfig | undefined,
getPanda: () => PanDomainAuthentication,
req: express.Request,
res: express.Response,
) {
const url = config?.url;
if (!url || typeof url != 'string' || url.length <= 0) {
res.status(400);
res.send({ error: 'No URL provided' });
return;
}
const salt = process.env.SALT;
if (!salt) {
res.status(500);
res.send({
error: 'Service incorrectly configured. No salt provided',
});
return;
}
const profile = config.profile ?? { width: DEFAULT_WIDTH };
try {
const signedUrl = format(url, salt, profile);
res.send({ signedUrl });
} catch (ex: unknown) {
res.status(500).send({
error: 'Error signing url',
ex: ex,
});
}
}