23 lines
510 B
TypeScript
23 lines
510 B
TypeScript
|
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');
|
||
|
}
|
||
|
});
|
||
|
};
|