- category wip

This commit is contained in:
2023-05-08 20:05:07 +02:00
parent 95ec75b8d7
commit 4ce9dae7ab
4 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,15 @@
import express, { Request, Response } from 'express';
import { prisma, __path } from '../../index.js';
export default (req: Request, res: Response) => {
prisma.category
.findMany({})
.then((items) => {
// Count amount of total items
res.render(__path + '/src/frontend/categoryManager.eta.html', { items: items });
})
.catch((err) => {
console.error(err);
res.status(500).render(__path + '/src/frontend/errors/dbError.eta.html', { error: err });
});
};

View File

@ -6,6 +6,7 @@ import testRoute from './test.js';
import dashboardRoute from './dashboard.js';
import csvImportRoute from './import/csvImport.js';
import listAllItems from './listAllItems.js';
import categoryManager from './categoryManager.js';
// Router base is '/'
const Router = express.Router({ strict: false });
@ -13,6 +14,7 @@ const Router = express.Router({ strict: false });
Router.use('/test', testRoute);
Router.use('/allItems', listAllItems)
Router.use('/allCategories', categoryManager)
Router.use('/import/csv', csvImportRoute);
Router.use('/:id(\\w{8})', skuRoute);
Router.use('/', dashboardRoute);