export const middlewarePath = 'middlewares';

export const middlewareTemplate = (name: string) => `import { Request, Response, NextFunction } from 'express';

/**
 * ${name}Middleware
 * A demo middleware for authentication / logging / validation etc.
 */
export const ${name}Middleware = (req: Request, res: Response, next: NextFunction) => {
  console.log('[Middleware] ${name} triggered on:', req.path);

  // Example logic: Check for a fake auth token
  const token = req.headers['authorization'];

  if (!token) {
    return res.status(401).json({ message: 'Unauthorized: No token provided' });
  }

  // Pass to next middleware or route handler
  next();
};
`;
