ca-grow-ops-manager/backend/src/routes/walkthrough.routes.ts
fullsizemalt 73958c5a5f
Some checks failed
Deploy to Production / deploy (push) Failing after 0s
Test / backend-test (push) Failing after 0s
Test / frontend-test (push) Failing after 1s
fix(backend): add auth middleware to walkthrough routes
2025-12-11 20:29:50 -08:00

32 lines
948 B
TypeScript

import { FastifyInstance } from 'fastify';
import {
createWalkthrough,
getWalkthroughs,
getWalkthrough,
completeWalkthrough,
addReservoirCheck,
addIrrigationCheck,
addPlantHealthCheck,
} from '../controllers/walkthrough.controller';
export async function walkthroughRoutes(server: FastifyInstance) {
// Auth middleware
server.addHook('onRequest', async (request) => {
try {
await request.jwtVerify();
} catch (err) {
throw err;
}
});
// Walkthrough CRUD
server.post('/', createWalkthrough);
server.get('/', getWalkthroughs);
server.get('/:id', getWalkthrough);
server.post('/:id/complete', completeWalkthrough);
// Add checks to walkthrough
server.post('/:id/reservoir-checks', addReservoirCheck);
server.post('/:id/irrigation-checks', addIrrigationCheck);
server.post('/:id/plant-health-checks', addPlantHealthCheck);
}