📦 Supply Items Backend (Phase 3A) ✅ Controller (supplies.controller.ts): - getSupplyItems() - List all items - getShoppingList() - Items below threshold - getSupplyItem() - Single item detail - createSupplyItem() - Add new item - updateSupplyItem() - Edit item - deleteSupplyItem() - Remove item - markAsOrdered() - Track last ordered date - adjustQuantity() - Add/subtract stock ✅ Routes (supplies.routes.ts): - GET /api/supplies - GET /api/supplies/shopping-list - GET /api/supplies/:id - POST /api/supplies - PATCH /api/supplies/:id - DELETE /api/supplies/:id - POST /api/supplies/:id/order - POST /api/supplies/:id/adjust ✅ Server Integration: - Registered supplies routes Next: Frontend UI + Migration
37 lines
992 B
TypeScript
37 lines
992 B
TypeScript
import { FastifyInstance } from 'fastify';
|
|
import {
|
|
getSupplyItems,
|
|
getShoppingList,
|
|
getSupplyItem,
|
|
createSupplyItem,
|
|
updateSupplyItem,
|
|
deleteSupplyItem,
|
|
markAsOrdered,
|
|
adjustQuantity,
|
|
} from '../controllers/supplies.controller';
|
|
|
|
export async function suppliesRoutes(server: FastifyInstance) {
|
|
// Get all supply items
|
|
server.get('/supplies', getSupplyItems);
|
|
|
|
// Get shopping list (items below threshold)
|
|
server.get('/supplies/shopping-list', getShoppingList);
|
|
|
|
// Get single supply item
|
|
server.get('/supplies/:id', getSupplyItem);
|
|
|
|
// Create supply item
|
|
server.post('/supplies', createSupplyItem);
|
|
|
|
// Update supply item
|
|
server.patch('/supplies/:id', updateSupplyItem);
|
|
|
|
// Delete supply item
|
|
server.delete('/supplies/:id', deleteSupplyItem);
|
|
|
|
// Mark item as ordered
|
|
server.post('/supplies/:id/order', markAsOrdered);
|
|
|
|
// Adjust quantity
|
|
server.post('/supplies/:id/adjust', adjustQuantity);
|
|
}
|