import express, { Request, Response } from 'express'; import { prisma, __path } from '../../index.js'; export default (req: Request, res: Response) => { // TODO: Fix it? Express behaves like fucking shit with routers and /. Do not ask about it or touch it. EVER! (But if you can fix it a PR is welcome!) if (req.originalUrl !== '/') { res.status(404).render(__path + '/src/frontend/errors/404.eta.html', { url: req.originalUrl }); } else { prisma.item .findMany({ orderBy: { updatedAt: 'desc' }, // Limit to 10 items take: 10 }) .then((items) => { // Count amount of total items prisma.item.count().then((count) => { res.render(__path + '/src/frontend/dashboard.eta.html', { recents: items, stats: { total: count } }); }); }) .catch((err) => { console.error(err); res.status(500).render(__path + '/src/frontend/errors/dbError.eta.html', { error: err }); }); } };