Fixed routing and publicInfoPage.
This commit is contained in:
@ -2,15 +2,28 @@ 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
|
||||
function get(req: Request, res: Response) {
|
||||
// Get data from database using sku from url.
|
||||
prisma.item
|
||||
.findFirst({
|
||||
where: {
|
||||
SKU: req.params.id
|
||||
},
|
||||
select: {
|
||||
SKU: true,
|
||||
name: true,
|
||||
comment: true,
|
||||
amount: true,
|
||||
// Get category name from relation.
|
||||
category: {
|
||||
select: {
|
||||
name: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.then((item) => {
|
||||
console.log(JSON.stringify(item));
|
||||
if (item) {
|
||||
Eta.renderFile(__path + '/src/frontend/publicInfoPage.eta.html', item).then((html) => {
|
||||
res.send(html);
|
||||
@ -19,4 +32,6 @@ export default (req: Request, res: Response) => {
|
||||
res.send('Item not found');
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export default { get };
|
||||
|
Reference in New Issue
Block a user