3 files changed
+17
-10
No files matched your search
@@ -1,17 +1,16 @@
|
||||
# ---------------------
|
||||
# Frontend build stage
|
||||
# ---------------------
|
||||
FROM node:20-slim AS frontend-build
|
||||
|
||||
|
||||
# Build on the host arch (BUILDPLATFORM) rather than under QEMU — the output is
|
||||
# pure JS so it's arch-independent, and this avoids the esbuild host/native
|
||||
# binary version mismatch under emulation.
|
||||
FROM --platform=$BUILDPLATFORM node:20-slim AS frontend-build
|
||||
|
||||
WORKDIR /app/client
|
||||
|
||||
COPY client/package.json ./
|
||||
COPY client/package*.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
RUN npm install esbuild@0.25.5 --build-from-source
|
||||
RUN npm ci
|
||||
|
||||
COPY client ./
|
||||
|
||||
|
||||
@@ -29,6 +29,14 @@ export const optionalString = (value: unknown, fieldName: string): string | unde
|
||||
throw new AppError({ message: `${fieldName} must be a string`, status: 400 });
|
||||
};
|
||||
|
||||
export const extractString = (value: unknown): string | undefined => {
|
||||
const candidate = Array.isArray(value) ? value[0] : value;
|
||||
if (typeof candidate !== "string" || candidate.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return candidate;
|
||||
};
|
||||
|
||||
export const optionalNumber = (value: unknown, fieldName: string): number | undefined => {
|
||||
if (value === undefined) {
|
||||
return undefined;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AppError } from "@/utils/AppError.js";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { requireTeamId, requireUserId, requireUserEmail } from "./controllerUtils.js";
|
||||
import { requireTeamId, requireUserId, requireUserEmail, extractString } from "./controllerUtils.js";
|
||||
import { IIncidentService } from "@/service/index.js";
|
||||
import { getIncidentsByTeamQueryValidation, getIncidentSummaryQueryValidation } from "@/validation/incidentValidation.js";
|
||||
|
||||
@@ -85,12 +85,12 @@ class IncidentController implements IIncidentController {
|
||||
const teamId = requireTeamId(req.user?.teamId);
|
||||
const userId = requireUserId(req.user?.id);
|
||||
const userEmail = requireUserEmail(req.user?.email);
|
||||
const incidentId = req.params?.incidentId;
|
||||
const incidentId = extractString(req.params?.incidentId);
|
||||
if (!incidentId) {
|
||||
throw new AppError({ message: "Incident ID is required", service: SERVICE_NAME, status: 400 });
|
||||
}
|
||||
|
||||
const comment = Array.isArray(req.body.comment) ? req.body.comment[0] : req.body.comment;
|
||||
const comment = extractString(req.body?.comment);
|
||||
const resolvedIncident = await this.incidentService.resolveIncident(incidentId, userId, teamId, comment, userEmail);
|
||||
|
||||
return res.status(200).json({
|
||||
|
||||
Reference in new issue
Block a user