assetflow/src/routes/frontend/:id.ts

23 lines
510 B
TypeScript
Raw Normal View History

2023-05-01 00:14:16 +02:00
import { Request, Response } from 'express';
import { prisma, __path } from '../../index.js';
import * as Eta from 'eta';
export default (req: Request, res: Response) => {
// retrieve data from database using id from url
prisma.item
.findFirst({
where: {
SKU: req.params.id
}
})
.then((item) => {
if (item) {
Eta.renderFile(__path + '/src/frontend/publicInfoPage.eta.html', item).then((html) => {
res.send(html);
});
} else {
res.send('Item not found');
}
});
};