All files / server/src/features/sentry-tunnel sentryTunnelController.ts

90% Statements 9/10
100% Branches 0/0
100% Functions 3/3
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30          39x       2x     2x 2x 2x           2x     39x 1x     1x    
import { Request, Response } from "express";
import { logger } from "server/utils/logger";
import { ApiEndpoint } from "shared/constants/apiEndpoints";
import { resendSentryRequest } from "server/features/sentry-tunnel/sentryTunnelService";
 
export const postSentryTunnel = (
  req: Request<unknown, unknown, Buffer>,
  res: Response,
): Response => {
  logger.info(`API call: POST ${ApiEndpoint.SENTRY_TUNNEL}`);
 
  // Fire-and-forget: respond to the Sentry client immediately without awaiting the resend
  void (async () => {
    try {
      await resendSentryRequest(req.body);
    } catch (error: unknown) {
      logger.error(new Error("resendSentryRequest failed", { cause: error }));
    }
  })();
 
  return res.sendStatus(200);
};
 
export const getSentryTest = (_req: Request, _res: Response): Response => {
  logger.error(new Error("Sentry test error: logger.error()"));
 
  // eslint-disable-next-line no-restricted-syntax -- Test error
  throw new Error("Sentry test error: uncaught exception");
};