Files
flyer-crawler.projectium.com/src/routes/price.routes.ts

36 lines
1.1 KiB
TypeScript

// src/routes/price.routes.ts
import { Router, Request, Response } from 'express';
import { z } from 'zod';
import { validateRequest } from '../middleware/validation.middleware';
const router = Router();
const priceHistorySchema = z.object({
body: z.object({
masterItemIds: z.array(z.number().int().positive()).nonempty({
message: 'masterItemIds must be a non-empty array of positive integers.',
}),
}),
});
// Infer the type from the schema for local use, as per ADR-003.
type PriceHistoryRequest = z.infer<typeof priceHistorySchema>;
/**
* POST /api/price-history - Fetches historical price data for a given list of master item IDs.
* This is a placeholder implementation.
*/
router.post('/', validateRequest(priceHistorySchema), async (req: Request, res: Response) => {
// Cast 'req' to the inferred type for full type safety.
const {
body: { masterItemIds },
} = req as unknown as PriceHistoryRequest;
req.log.info(
{ itemCount: masterItemIds.length },
'[API /price-history] Received request for historical price data.',
);
res.status(200).json([]);
});
export default router;