Revived the page! He's baaaaack

This commit is contained in:
2026-01-27 10:01:41 -05:00
parent 7c7cbef3f3
commit 67562f56aa
9 changed files with 469 additions and 95 deletions

29
api/src/routes/units.ts Normal file
View File

@@ -0,0 +1,29 @@
import express = require('express');
const unitsRouter = express.Router();
import pool from '../db';
import { requireLogin } from '../middleware/auth';
import { logger } from '../services/logging/logger';
import { Unit } from '@app/shared/types/units';
unitsRouter.use(requireLogin);
//get all units
unitsRouter.get('/', async (req, res) => {
try {
const result: Unit[] = await pool.query('SELECT * FROM units WHERE active = 1;');
res.json(result);
} catch (error) {
logger.error(
'app',
'Failed to get all units',
{
error: error instanceof Error ? error.message : String(error),
stack: error instanceof Error ? error.stack : undefined,
}
);
res.sendStatus(500);
}
});
export const units = unitsRouter;