import type { RequestHandler } from 'express';
import { isProduction } from '../config';
import { errorResponse } from '../utils/errorHandler';

/**
 * Middleware that blocks requests in production environments.
 * Apply to mock/sandbox-only endpoints that must not be callable in production.
 */
export const requireNonProduction: RequestHandler = (_req, res, next) => {
  if (isProduction()) {
    res.status(403).json(
      errorResponse('ENDPOINT_DISABLED_IN_PRODUCTION', 'Use /v1/subscriptions/checkout instead')
    );
    return;
  }
  next();
};
