import { NextFunction, Request, Response } from "express" import { WSQuery } from "../types" // Validate input parameters const validateParamsMiddleware = (MPLABS_ID: string, MPLABS_PASSWORD: string) => (req: Request, res: Response, next: NextFunction) => { const { ID, PASSWORD, action, dateutc } = req.query as WSQuery // Validate action and dateutc if (action !== 'updateraww') { res.status(400).send('Invalid action') } else if (dateutc !== 'now' && isNaN(Date.parse(dateutc))) { res.status(400).send('Invalid dateutc format') } // Validate ID and PASSWORD (this is where you would verify against your database) // For now, we'll mock this validation else if (ID !== MPLABS_ID || PASSWORD !== MPLABS_PASSWORD) { return res.status(401).send('INVALIDPASSWORDID|Password and/or id are incorrect') } else { next() } } export default validateParamsMiddleware