ca-grow-ops-manager/backend/src/controllers/batches.controller.ts
fullsizemalt 6b724386ba
Some checks failed
Deploy to Production / deploy (push) Failing after 0s
Test / backend-test (push) Failing after 0s
Test / frontend-test (push) Failing after 0s
feat: Phase 1 Complete (Backend + Frontend)
2025-12-09 09:24:00 -08:00

24 lines
683 B
TypeScript

import { FastifyRequest, FastifyReply } from 'fastify';
export const getBatches = async (request: FastifyRequest, reply: FastifyReply) => {
const batches = await request.server.prisma.batch.findMany({
include: { room: true },
orderBy: { startDate: 'desc' }
});
return batches;
};
export const createBatch = async (request: FastifyRequest, reply: FastifyReply) => {
const { name, strain, roomId, startDate } = request.body as any;
const batch = await request.server.prisma.batch.create({
data: {
name,
strain,
startDate: new Date(startDate),
roomId
}
});
return batch;
};