Redesign
This commit is contained in:
@@ -8,7 +8,6 @@ import { FastifyPluginAsync } from 'fastify';
|
||||
// Types handled in controllers; no explicit generics required here
|
||||
import { FuelLogsController } from './fuel-logs.controller';
|
||||
import { FuelGradeController } from './fuel-grade.controller';
|
||||
import { tenantMiddleware } from '../../../core/middleware/tenant';
|
||||
|
||||
export const fuelLogsRoutes: FastifyPluginAsync = async (
|
||||
fastify: FastifyInstance,
|
||||
@@ -19,53 +18,53 @@ export const fuelLogsRoutes: FastifyPluginAsync = async (
|
||||
|
||||
// GET /api/fuel-logs - Get user's fuel logs
|
||||
fastify.get('/fuel-logs', {
|
||||
preHandler: [fastify.authenticate, tenantMiddleware],
|
||||
preHandler: [fastify.authenticate],
|
||||
handler: fuelLogsController.getUserFuelLogs.bind(fuelLogsController)
|
||||
});
|
||||
|
||||
// POST /api/fuel-logs - Create new fuel log
|
||||
fastify.post('/fuel-logs', {
|
||||
preHandler: [fastify.authenticate, tenantMiddleware],
|
||||
preHandler: [fastify.authenticate],
|
||||
handler: fuelLogsController.createFuelLog.bind(fuelLogsController)
|
||||
});
|
||||
|
||||
// GET /api/fuel-logs/:id - Get specific fuel log
|
||||
fastify.get('/fuel-logs/:id', {
|
||||
preHandler: [fastify.authenticate, tenantMiddleware],
|
||||
preHandler: [fastify.authenticate],
|
||||
handler: fuelLogsController.getFuelLog.bind(fuelLogsController)
|
||||
});
|
||||
|
||||
// PUT /api/fuel-logs/:id - Update fuel log
|
||||
fastify.put('/fuel-logs/:id', {
|
||||
preHandler: [fastify.authenticate, tenantMiddleware],
|
||||
preHandler: [fastify.authenticate],
|
||||
handler: fuelLogsController.updateFuelLog.bind(fuelLogsController)
|
||||
});
|
||||
|
||||
// DELETE /api/fuel-logs/:id - Delete fuel log
|
||||
fastify.delete('/fuel-logs/:id', {
|
||||
preHandler: [fastify.authenticate, tenantMiddleware],
|
||||
preHandler: [fastify.authenticate],
|
||||
handler: fuelLogsController.deleteFuelLog.bind(fuelLogsController)
|
||||
});
|
||||
|
||||
// NEW ENDPOINTS under /api/fuel-logs
|
||||
fastify.get('/fuel-logs/vehicle/:vehicleId', {
|
||||
preHandler: [fastify.authenticate, tenantMiddleware],
|
||||
preHandler: [fastify.authenticate],
|
||||
handler: fuelLogsController.getFuelLogsByVehicle.bind(fuelLogsController)
|
||||
});
|
||||
|
||||
fastify.get('/fuel-logs/vehicle/:vehicleId/stats', {
|
||||
preHandler: [fastify.authenticate, tenantMiddleware],
|
||||
preHandler: [fastify.authenticate],
|
||||
handler: fuelLogsController.getFuelStats.bind(fuelLogsController)
|
||||
});
|
||||
|
||||
// Fuel type/grade discovery
|
||||
fastify.get('/fuel-logs/fuel-types', {
|
||||
preHandler: [fastify.authenticate, tenantMiddleware],
|
||||
preHandler: [fastify.authenticate],
|
||||
handler: fuelGradeController.getAllFuelTypes.bind(fuelGradeController)
|
||||
});
|
||||
|
||||
fastify.get('/fuel-logs/fuel-grades/:fuelType', {
|
||||
preHandler: [fastify.authenticate, tenantMiddleware],
|
||||
preHandler: [fastify.authenticate],
|
||||
handler: fuelGradeController.getFuelGrades.bind(fuelGradeController)
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user