365 files changed
+10339
-6608
No files matched your search
@@ -68,19 +68,23 @@ VITE_APP_LOG_LEVEL="debug"
|
|||||||
### Backend Layers
|
### Backend Layers
|
||||||
```
|
```
|
||||||
server/src/
|
server/src/
|
||||||
├── controllers/ # Route handlers (authController, monitorController, etc.)
|
├── api/ # HTTP layer
|
||||||
├── service/ # Business logic
|
│ ├── controllers/ # Route handlers (authController, monitorController, etc.)
|
||||||
│ ├── business/ # Core monitoring logic
|
│ ├── middleware/ # verifyJWT, rateLimiter, sanitization, responseHandler
|
||||||
│ ├── infrastructure/ # Server/system utilities
|
│ ├── routes/ # API route definitions
|
||||||
│ └── system/ # App-level settings
|
│ └── validation/ # Zod request-payload schemas
|
||||||
|
├── domain/ # Business logic + data access, one folder per entity
|
||||||
|
│ ├── monitors/ # e.g. monitor.service.ts, monitor.repository.ts, monitor.type.ts
|
||||||
|
│ ├── checks/
|
||||||
|
│ ├── incidents/
|
||||||
|
│ └── … # users, teams, status-pages, notifications, etc.
|
||||||
|
├── service/ # Cross-cutting services (e.g. infrastructure/)
|
||||||
|
├── config/ # App config wiring (controllers, routes, services, envValidation)
|
||||||
├── db/
|
├── db/
|
||||||
│ ├── models/ # Mongoose schemas (Monitor, Check, Incident, User, etc.)
|
│ └── migration/ # Database migrations (run on startup)
|
||||||
│ ├── migration/ # Database migrations (run on startup)
|
├── templates/ # Email/notification templates
|
||||||
│ └── modules/ # Database-specific modules
|
├── types/ # Shared const tuples + derived types
|
||||||
├── middleware/v1/ # verifyJWT, rateLimiter, sanitization, responseHandler
|
└── utils/ # Shared utilities
|
||||||
├── routes/v1/ # API route definitions
|
|
||||||
├── validation/ # Joi input validation schemas
|
|
||||||
└── repositories/ # Data access layer
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Frontend Structure
|
### Frontend Structure
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"version": "3.8.1",
|
"version": "3.9.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"version": "3.8.1",
|
"version": "3.9.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "3.8.1",
|
"version": "3.9.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
"format-check": "prettier --check ."
|
"format-check": "prettier --check ."
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"**/*": "prettier --write"
|
"**/*": "prettier --write --ignore-unknown"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { monitorSchema, type MonitorFormData } from "@/Validation/monitor";
|
import { monitorSchema, type MonitorFormData } from "@/Validation/monitor";
|
||||||
import { DefaultPageSpeedStrategy } from "@/Types/Monitor";
|
import { DefaultHttpMethod, DefaultPageSpeedStrategy } from "@/Types/Monitor";
|
||||||
import type { Monitor, MonitorType } from "@/Types/Monitor";
|
import type { Monitor, MonitorType } from "@/Types/Monitor";
|
||||||
|
|
||||||
interface UseMonitorFormOptions {
|
interface UseMonitorFormOptions {
|
||||||
@@ -40,11 +40,13 @@ export const getMonitorDefaults = (
|
|||||||
...getGeoCheckDefaults(data),
|
...getGeoCheckDefaults(data),
|
||||||
type: "http",
|
type: "http",
|
||||||
url: data?.url || "",
|
url: data?.url || "",
|
||||||
|
method: data?.method ?? DefaultHttpMethod,
|
||||||
ignoreTlsErrors: data?.ignoreTlsErrors || false,
|
ignoreTlsErrors: data?.ignoreTlsErrors || false,
|
||||||
useAdvancedMatching: data?.useAdvancedMatching || false,
|
useAdvancedMatching: data?.useAdvancedMatching || false,
|
||||||
matchMethod: data?.matchMethod || "",
|
matchMethod: data?.matchMethod || "",
|
||||||
expectedValue: data?.expectedValue || "",
|
expectedValue: data?.expectedValue || "",
|
||||||
jsonPath: data?.jsonPath || "",
|
jsonPath: data?.jsonPath || "",
|
||||||
|
customUpCodes: data?.customUpCodes || [],
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "ping":
|
case "ping":
|
||||||
@@ -133,11 +135,13 @@ export const getMonitorDefaults = (
|
|||||||
...getGeoCheckDefaults(data),
|
...getGeoCheckDefaults(data),
|
||||||
type: "http",
|
type: "http",
|
||||||
url: "",
|
url: "",
|
||||||
|
method: DefaultHttpMethod,
|
||||||
ignoreTlsErrors: false,
|
ignoreTlsErrors: false,
|
||||||
useAdvancedMatching: false,
|
useAdvancedMatching: false,
|
||||||
matchMethod: "",
|
matchMethod: "",
|
||||||
expectedValue: "",
|
expectedValue: "",
|
||||||
jsonPath: "",
|
jsonPath: "",
|
||||||
|
customUpCodes: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export const useStatusPageForm = ({
|
|||||||
const defaults: StatusPageFormData = {
|
const defaults: StatusPageFormData = {
|
||||||
companyName: data?.companyName || "",
|
companyName: data?.companyName || "",
|
||||||
url: data?.url || generateDefaultUrl(),
|
url: data?.url || generateDefaultUrl(),
|
||||||
|
customDomain: data?.customDomain ?? null,
|
||||||
timezone: resolveTimezone(data?.timezone),
|
timezone: resolveTimezone(data?.timezone),
|
||||||
type: data?.type || ["uptime"],
|
type: data?.type || ["uptime"],
|
||||||
color: data?.color || "#13715B",
|
color: data?.color || "#13715B",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { logger } from "@/Utils/logger";
|
import { logger } from "@/Utils/logger";
|
||||||
|
import { ALL_HTTP_STATUS_CODES } from "@/Utils/statusCode";
|
||||||
import { useParams, useLocation, useNavigate } from "react-router";
|
import { useParams, useLocation, useNavigate } from "react-router";
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
@@ -41,8 +42,11 @@ import {
|
|||||||
type Monitor,
|
type Monitor,
|
||||||
type MonitorType,
|
type MonitorType,
|
||||||
type GamesMap,
|
type GamesMap,
|
||||||
|
type HttpMethod,
|
||||||
supportsGeoCheck,
|
supportsGeoCheck,
|
||||||
DefaultPageSpeedStrategy,
|
DefaultPageSpeedStrategy,
|
||||||
|
DefaultHttpMethod,
|
||||||
|
HttpMethods,
|
||||||
} from "@/Types/Monitor";
|
} from "@/Types/Monitor";
|
||||||
import type { Notification } from "@/Types/Notification";
|
import type { Notification } from "@/Types/Notification";
|
||||||
import type { Tag } from "@/Types/Tag";
|
import type { Tag } from "@/Types/Tag";
|
||||||
@@ -258,7 +262,7 @@ const CreateMonitorPage = () => {
|
|||||||
resolver: zodResolver(schema),
|
resolver: zodResolver(schema),
|
||||||
defaultValues: defaults,
|
defaultValues: defaults,
|
||||||
});
|
});
|
||||||
const { control, watch, handleSubmit, clearErrors, trigger, reset } = form;
|
const { control, watch, handleSubmit, clearErrors, trigger, reset, setValue } = form;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
reset(defaults);
|
reset(defaults);
|
||||||
@@ -270,6 +274,7 @@ const CreateMonitorPage = () => {
|
|||||||
const showStep = (step: number) => isEditMode || currentStep === step;
|
const showStep = (step: number) => isEditMode || currentStep === step;
|
||||||
|
|
||||||
const watchedType = watch("type") as MonitorType;
|
const watchedType = watch("type") as MonitorType;
|
||||||
|
const watchedMethod = watch("method") as HttpMethod | undefined;
|
||||||
const watchedUseAdvancedMatching = watch("useAdvancedMatching") as boolean;
|
const watchedUseAdvancedMatching = watch("useAdvancedMatching") as boolean;
|
||||||
const watchGeoCheckEnabled = watch("geoCheckEnabled") as boolean;
|
const watchGeoCheckEnabled = watch("geoCheckEnabled") as boolean;
|
||||||
|
|
||||||
@@ -1091,27 +1096,144 @@ const CreateMonitorPage = () => {
|
|||||||
rightContent={
|
rightContent={
|
||||||
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
<Controller
|
<Controller
|
||||||
name="useAdvancedMatching"
|
name="method"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Stack
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
direction="row"
|
<Select
|
||||||
alignItems="center"
|
{...field}
|
||||||
spacing={theme.spacing(SPACING.LG)}
|
value={field.value ?? DefaultHttpMethod}
|
||||||
>
|
onChange={(e) => {
|
||||||
<Switch
|
const value = e.target.value as HttpMethod;
|
||||||
checked={field.value ?? false}
|
field.onChange(value);
|
||||||
onChange={(e) => field.onChange(e.target.checked)}
|
// HEAD has no response body, reset advanced matching fields if selected
|
||||||
/>
|
if (value === "HEAD") {
|
||||||
<Typography>
|
setValue("useAdvancedMatching", false);
|
||||||
|
setValue("matchMethod", "");
|
||||||
|
setValue("expectedValue", "");
|
||||||
|
setValue("jsonPath", "");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
fieldLabel={t(
|
||||||
|
"pages.createMonitor.form.advanced.option.method.label"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{HttpMethods.map((method) => (
|
||||||
|
<MenuItem
|
||||||
|
key={method}
|
||||||
|
value={method}
|
||||||
|
>
|
||||||
|
{method}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
color={theme.palette.text.secondary}
|
||||||
|
sx={{ opacity: 0.8 }}
|
||||||
|
>
|
||||||
{t(
|
{t(
|
||||||
"pages.createMonitor.form.advanced.option.advancedMatching.label"
|
`pages.createMonitor.form.advanced.option.method.description.${field.value ?? DefaultHttpMethod}`
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{watchedUseAdvancedMatching && (
|
<Controller
|
||||||
|
name="customUpCodes"
|
||||||
|
control={control}
|
||||||
|
render={({ field }) => {
|
||||||
|
const selectedOptions = ALL_HTTP_STATUS_CODES.filter((option) =>
|
||||||
|
field.value?.includes(option.id)
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
|
<Autocomplete
|
||||||
|
multiple
|
||||||
|
autoHighlight
|
||||||
|
options={ALL_HTTP_STATUS_CODES}
|
||||||
|
value={selectedOptions}
|
||||||
|
getOptionLabel={(option) => option.name}
|
||||||
|
isOptionEqualToValue={(option, value) => option.id === value.id}
|
||||||
|
onChange={(
|
||||||
|
_: unknown,
|
||||||
|
newValue: typeof ALL_HTTP_STATUS_CODES
|
||||||
|
) => {
|
||||||
|
field.onChange(newValue?.map((v) => v.id) || []);
|
||||||
|
}}
|
||||||
|
fieldLabel={t(
|
||||||
|
"pages.createMonitor.form.advanced.option.customUpCodes.label"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
color={theme.palette.text.secondary}
|
||||||
|
sx={{ opacity: 0.8 }}
|
||||||
|
>
|
||||||
|
{t(
|
||||||
|
"pages.createMonitor.form.advanced.option.customUpCodes.description"
|
||||||
|
)}
|
||||||
|
</Typography>
|
||||||
|
{selectedOptions.length > 0 && (
|
||||||
|
<Stack
|
||||||
|
flex={1}
|
||||||
|
gap={theme.spacing(SPACING.MD)}
|
||||||
|
width="100%"
|
||||||
|
>
|
||||||
|
{selectedOptions.map((option, index) => (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
key={option.id}
|
||||||
|
width="100%"
|
||||||
|
>
|
||||||
|
<Typography flexGrow={1}>{option.name}</Typography>
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
onClick={() => {
|
||||||
|
field.onChange(
|
||||||
|
field.value?.filter((id) => id !== option.id)
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
aria-label={t(
|
||||||
|
"pages.createMonitor.form.advanced.option.customUpCodes.removeAriaLabel"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</IconButton>
|
||||||
|
{index < selectedOptions.length - 1 && <Divider />}
|
||||||
|
</Stack>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{watchedMethod !== "HEAD" && (
|
||||||
|
<Controller
|
||||||
|
name="useAdvancedMatching"
|
||||||
|
control={control}
|
||||||
|
render={({ field }) => (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
spacing={theme.spacing(SPACING.LG)}
|
||||||
|
>
|
||||||
|
<Switch
|
||||||
|
checked={field.value ?? false}
|
||||||
|
onChange={(e) => field.onChange(e.target.checked)}
|
||||||
|
/>
|
||||||
|
<Typography>
|
||||||
|
{t(
|
||||||
|
"pages.createMonitor.form.advanced.option.advancedMatching.label"
|
||||||
|
)}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{watchedUseAdvancedMatching && watchedMethod !== "HEAD" && (
|
||||||
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
<Controller
|
<Controller
|
||||||
name="matchMethod"
|
name="matchMethod"
|
||||||
|
|||||||
@@ -33,6 +33,26 @@ export const MongoStats = ({ diagnostics }: MongoStatsProps) => {
|
|||||||
title={t("pages.logs.diagnostics.mongoDBStats.readyState")}
|
title={t("pages.logs.diagnostics.mongoDBStats.readyState")}
|
||||||
subtitle={mongoStats.readyState.toString()}
|
subtitle={mongoStats.readyState.toString()}
|
||||||
/>
|
/>
|
||||||
|
<StatBox
|
||||||
|
title={t("pages.logs.diagnostics.mongoDBStats.readsPerSecond")}
|
||||||
|
subtitle={mongoStats.readsPerSecond.toFixed(0)}
|
||||||
|
/>
|
||||||
|
<StatBox
|
||||||
|
title={t("pages.logs.diagnostics.mongoDBStats.insertsPerSecond")}
|
||||||
|
subtitle={mongoStats.insertsPerSecond.toFixed(0)}
|
||||||
|
/>
|
||||||
|
<StatBox
|
||||||
|
title={t("pages.logs.diagnostics.mongoDBStats.updatesPerSecond")}
|
||||||
|
subtitle={mongoStats.updatesPerSecond.toFixed(0)}
|
||||||
|
/>
|
||||||
|
<StatBox
|
||||||
|
title={t("pages.logs.diagnostics.mongoDBStats.deletesPerSecond")}
|
||||||
|
subtitle={mongoStats.deletesPerSecond.toFixed(0)}
|
||||||
|
/>
|
||||||
|
<StatBox
|
||||||
|
title={t("pages.logs.diagnostics.mongoDBStats.writesPerSecond")}
|
||||||
|
subtitle={mongoStats.writesPerSecond.toFixed(0)}
|
||||||
|
/>
|
||||||
<StatBox
|
<StatBox
|
||||||
title={t("pages.logs.diagnostics.mongoDBStats.host")}
|
title={t("pages.logs.diagnostics.mongoDBStats.host")}
|
||||||
subtitle={mongoStats.host}
|
subtitle={mongoStats.host}
|
||||||
|
|||||||
@@ -42,12 +42,15 @@ export const TableJobs = ({
|
|||||||
maxWidth: 220,
|
maxWidth: 220,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isRunning = (row: QueueJobWithId) =>
|
||||||
|
row.lockedBy !== null && row.lockedUntil !== null && row.lockedUntil > Date.now();
|
||||||
|
|
||||||
const headers: Header<QueueJobWithId>[] = [
|
const headers: Header<QueueJobWithId>[] = [
|
||||||
{
|
{
|
||||||
id: "state",
|
id: "state",
|
||||||
content: t("pages.logs.table.headers.state"),
|
content: t("pages.logs.table.headers.state"),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
if (row.lockedAt) {
|
if (isRunning(row)) {
|
||||||
return t("common.labels.running");
|
return t("common.labels.running");
|
||||||
}
|
}
|
||||||
if (row.monitorActive === true) {
|
if (row.monitorActive === true) {
|
||||||
@@ -72,18 +75,6 @@ export const TableJobs = ({
|
|||||||
</Typography>
|
</Typography>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: "url",
|
|
||||||
content: t("common.table.headers.url"),
|
|
||||||
render: (row) => (
|
|
||||||
<Typography
|
|
||||||
title={row.monitorUrl ?? ""}
|
|
||||||
sx={cellSx}
|
|
||||||
>
|
|
||||||
{row.monitorUrl}
|
|
||||||
</Typography>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: "type",
|
id: "type",
|
||||||
content: t("common.table.headers.type"),
|
content: t("common.table.headers.type"),
|
||||||
@@ -92,50 +83,36 @@ export const TableJobs = ({
|
|||||||
{
|
{
|
||||||
id: "interval",
|
id: "interval",
|
||||||
content: t("common.table.headers.interval"),
|
content: t("common.table.headers.interval"),
|
||||||
render: (row) => {
|
render: (row) => (
|
||||||
let interval;
|
<Typography sx={cellSx}>{prettyMilliseconds(row.monitorInterval ?? 0)}</Typography>
|
||||||
if (row.monitorId.toString().includes("geo")) {
|
),
|
||||||
interval = row.monitorGeoInterval ?? 0;
|
|
||||||
} else {
|
|
||||||
interval = row.repeat ?? 0;
|
|
||||||
}
|
|
||||||
return <Typography sx={cellSx}>{prettyMilliseconds(interval)}</Typography>;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "lastRun",
|
id: "lastFinishedAt",
|
||||||
content: t("pages.logs.table.headers.lastRunAt"),
|
content: t("pages.logs.table.headers.lastFinishedAt"),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
const v = formatTimestamp(row.lastRunAt) ?? "-";
|
const lastFinishedAt = formatTimestamp(row.lastFinishedAt) ?? "-";
|
||||||
return (
|
return (
|
||||||
<Typography
|
<Typography
|
||||||
title={v}
|
title={lastFinishedAt}
|
||||||
sx={cellSx}
|
sx={cellSx}
|
||||||
>
|
>
|
||||||
{v}
|
{lastFinishedAt}
|
||||||
</Typography>
|
</Typography>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "lastRunTook",
|
id: "nextScheduledAt",
|
||||||
content: t("pages.logs.table.headers.lastRunTook"),
|
content: t("pages.logs.table.headers.nextScheduledAt"),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
const value = row.lastRunTook ? prettyMilliseconds(row.lastRunTook) : "-";
|
const nextScheduledAt = formatTimestamp(row.nextScheduledAt) ?? "-";
|
||||||
return <Typography sx={cellSx}>{value}</Typography>;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "lockedAt",
|
|
||||||
content: t("pages.logs.table.headers.lockedAt"),
|
|
||||||
render: (row) => {
|
|
||||||
const v = formatTimestamp(row.lockedAt) ?? "-";
|
|
||||||
return (
|
return (
|
||||||
<Typography
|
<Typography
|
||||||
title={v}
|
title={nextScheduledAt}
|
||||||
sx={cellSx}
|
sx={cellSx}
|
||||||
>
|
>
|
||||||
{v}
|
{nextScheduledAt}
|
||||||
</Typography>
|
</Typography>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -169,7 +146,7 @@ export const TableJobs = ({
|
|||||||
headers={headers}
|
headers={headers}
|
||||||
data={jobsWithId}
|
data={jobsWithId}
|
||||||
getRowSx={(row) => ({
|
getRowSx={(row) => ({
|
||||||
...(row.lockedAt && {
|
...(isRunning(row) && {
|
||||||
"& td": { backgroundColor: theme.palette.rowStatus.running },
|
"& td": { backgroundColor: theme.palette.rowStatus.running },
|
||||||
}),
|
}),
|
||||||
...(row.monitorActive === false && {
|
...(row.monitorActive === false && {
|
||||||
|
|||||||
@@ -151,6 +151,11 @@ const CreateStatusPage = () => {
|
|||||||
fd.append("isPublished", String(data.isPublished));
|
fd.append("isPublished", String(data.isPublished));
|
||||||
if (data.companyName) fd.append("companyName", data.companyName);
|
if (data.companyName) fd.append("companyName", data.companyName);
|
||||||
if (data.url) fd.append("url", data.url);
|
if (data.url) fd.append("url", data.url);
|
||||||
|
if (data.customDomain !== undefined && data.customDomain !== null) {
|
||||||
|
fd.append("customDomain", data.customDomain);
|
||||||
|
} else {
|
||||||
|
fd.append("customDomain", "");
|
||||||
|
}
|
||||||
if (data.timezone) fd.append("timezone", data.timezone);
|
if (data.timezone) fd.append("timezone", data.timezone);
|
||||||
if (data.color) fd.append("color", data.color);
|
if (data.color) fd.append("color", data.color);
|
||||||
fd.append("showCharts", String(data.showCharts));
|
fd.append("showCharts", String(data.showCharts));
|
||||||
@@ -284,6 +289,27 @@ const CreateStatusPage = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<Controller
|
||||||
|
name="customDomain"
|
||||||
|
control={control}
|
||||||
|
render={({ field, fieldState }) => (
|
||||||
|
<TextField
|
||||||
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
|
fieldLabel={t(
|
||||||
|
"pages.statusPages.form.basicInfo.option.customDomain.label"
|
||||||
|
)}
|
||||||
|
placeholder={t(
|
||||||
|
"pages.statusPages.form.basicInfo.option.customDomain.placeholder"
|
||||||
|
)}
|
||||||
|
helperText={
|
||||||
|
fieldState.error?.message ||
|
||||||
|
t("pages.statusPages.form.basicInfo.option.customDomain.helper")
|
||||||
|
}
|
||||||
|
error={!!fieldState.error}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import { Settings, ExternalLink } from "lucide-react";
|
|||||||
import { useTheme } from "@mui/material";
|
import { useTheme } from "@mui/material";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { PUBLIC_STATUS_PAGE_PREFIX, type StatusPage } from "@/Types/StatusPage";
|
import { type StatusPage } from "@/Types/StatusPage";
|
||||||
|
import { getStatusPagePublicUrl } from "@/Utils/statusPageUrl";
|
||||||
|
|
||||||
interface HeaderStatusPageControlsProps {
|
interface HeaderStatusPageControlsProps {
|
||||||
isAdmin: boolean;
|
isAdmin: boolean;
|
||||||
@@ -50,7 +51,7 @@ export const HeaderStatusPageControls = ({
|
|||||||
<Typography
|
<Typography
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
window.open(
|
window.open(
|
||||||
`${PUBLIC_STATUS_PAGE_PREFIX}/${statusPage.url}`,
|
getStatusPagePublicUrl(statusPage),
|
||||||
"_blank",
|
"_blank",
|
||||||
"noopener,noreferrer"
|
"noopener,noreferrer"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ import {
|
|||||||
type StatusPageResponse,
|
type StatusPageResponse,
|
||||||
type StatusPageTheme,
|
type StatusPageTheme,
|
||||||
} from "@/Types/StatusPage";
|
} from "@/Types/StatusPage";
|
||||||
|
import {
|
||||||
|
buildStatusPageApiPath,
|
||||||
|
getStatusPagePublicUrl,
|
||||||
|
isCustomDomainHost,
|
||||||
|
} from "@/Utils/statusPageUrl";
|
||||||
import { HeaderStatusPageControls } from "@/Pages/StatusPage/Status/Components/HeaderStatusPageControls";
|
import { HeaderStatusPageControls } from "@/Pages/StatusPage/Status/Components/HeaderStatusPageControls";
|
||||||
import { StatusPageThemeProvider } from "@/Pages/StatusPage/Status/themes/StatusPageThemeProvider";
|
import { StatusPageThemeProvider } from "@/Pages/StatusPage/Status/themes/StatusPageThemeProvider";
|
||||||
import {
|
import {
|
||||||
@@ -67,9 +72,14 @@ const StatusPageView = () => {
|
|||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const isPublic = location.pathname.startsWith(PUBLIC_STATUS_PAGE_PREFIX);
|
const onCustomDomainHost = isCustomDomainHost();
|
||||||
|
const isPublic =
|
||||||
|
onCustomDomainHost || location.pathname.startsWith(PUBLIC_STATUS_PAGE_PREFIX);
|
||||||
|
|
||||||
const apiUrl = url ? `/status-page/${url}?type=uptime&type=infrastructure` : null;
|
const apiUrl = buildStatusPageApiPath({
|
||||||
|
url,
|
||||||
|
useCustomDomain: onCustomDomainHost,
|
||||||
|
});
|
||||||
|
|
||||||
const { data, isLoading, error } = useGet<StatusPageResponse>(
|
const { data, isLoading, error } = useGet<StatusPageResponse>(
|
||||||
apiUrl,
|
apiUrl,
|
||||||
@@ -134,7 +144,7 @@ const StatusPageView = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicUrl = `${window.location.origin}${PUBLIC_STATUS_PAGE_PREFIX}/${statusPage.url}`;
|
const publicUrl = getStatusPagePublicUrl(statusPage);
|
||||||
return (
|
return (
|
||||||
<BasePage
|
<BasePage
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
|
|||||||
@@ -99,9 +99,9 @@ export const boldStyles = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
top: {
|
top: {
|
||||||
display: "flex",
|
alignItems: { xs: "flex-start", md: "center" },
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
|
gap: "12px",
|
||||||
mb: "36px",
|
mb: "36px",
|
||||||
},
|
},
|
||||||
brand: {
|
brand: {
|
||||||
@@ -130,7 +130,7 @@ export const boldStyles = (
|
|||||||
hero: {
|
hero: {
|
||||||
position: "relative",
|
position: "relative",
|
||||||
borderRadius: "22px",
|
borderRadius: "22px",
|
||||||
padding: "36px 36px 32px",
|
padding: { xs: "24px 20px", md: "36px 36px 32px" },
|
||||||
mb: "28px",
|
mb: "28px",
|
||||||
background: isDark ? heroBgDark : heroBgLight,
|
background: isDark ? heroBgDark : heroBgLight,
|
||||||
border: `1px solid ${tokens.border}`,
|
border: `1px solid ${tokens.border}`,
|
||||||
@@ -149,13 +149,14 @@ export const boldStyles = (
|
|||||||
},
|
},
|
||||||
heroTitle: {
|
heroTitle: {
|
||||||
m: 0,
|
m: 0,
|
||||||
fontSize: 34,
|
fontSize: { xs: 24, md: 34 },
|
||||||
fontWeight: 800,
|
fontWeight: 800,
|
||||||
letterSpacing: "-0.02em",
|
letterSpacing: "-0.02em",
|
||||||
lineHeight: 1.1,
|
lineHeight: 1.1,
|
||||||
color: tokens.text,
|
color: tokens.text,
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: { xs: "flex-start", md: "center" },
|
||||||
|
flexWrap: "wrap",
|
||||||
gap: "10px",
|
gap: "10px",
|
||||||
},
|
},
|
||||||
heroCheck: (tone) => ({
|
heroCheck: (tone) => ({
|
||||||
@@ -171,9 +172,15 @@ export const boldStyles = (
|
|||||||
}),
|
}),
|
||||||
heroSub: { mt: "10px", mb: 0, color: tokens.textMuted, fontSize: 14 },
|
heroSub: { mt: "10px", mb: 0, color: tokens.textMuted, fontSize: 14 },
|
||||||
|
|
||||||
chartSwitchWrap: { display: "flex", justifyContent: "flex-end", mb: "16px" },
|
chartSwitchWrap: {
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: { xs: "center", md: "flex-end" },
|
||||||
|
mb: "16px",
|
||||||
|
},
|
||||||
chartSwitch: {
|
chartSwitch: {
|
||||||
display: "inline-flex",
|
display: "inline-flex",
|
||||||
|
width: { xs: "100%", md: "auto" },
|
||||||
|
maxWidth: "100%",
|
||||||
border: `1px solid ${tokens.border}`,
|
border: `1px solid ${tokens.border}`,
|
||||||
borderRadius: "999px",
|
borderRadius: "999px",
|
||||||
background: tokens.surface,
|
background: tokens.surface,
|
||||||
@@ -181,16 +188,20 @@ export const boldStyles = (
|
|||||||
gap: "2px",
|
gap: "2px",
|
||||||
},
|
},
|
||||||
chartSwitchButton: (active) => ({
|
chartSwitchButton: (active) => ({
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 0,
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
textAlign: "center",
|
||||||
border: 0,
|
border: 0,
|
||||||
background: active ? tokens.upSoft : "transparent",
|
background: active ? tokens.upSoft : "transparent",
|
||||||
fontFamily: "inherit",
|
fontFamily: "inherit",
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
padding: "8px 18px",
|
padding: { xs: "8px 6px", md: "8px 18px" },
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
color: active ? tokens.up : tokens.textMuted,
|
color: active ? tokens.up : tokens.textMuted,
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
textTransform: "uppercase",
|
textTransform: "uppercase",
|
||||||
letterSpacing: "0.12em",
|
letterSpacing: { xs: "0.04em", md: "0.12em" },
|
||||||
transition: "background 0.2s, color 0.2s",
|
transition: "background 0.2s, color 0.2s",
|
||||||
borderRadius: "999px",
|
borderRadius: "999px",
|
||||||
"&:hover": { color: active ? tokens.up : tokens.text },
|
"&:hover": { color: active ? tokens.up : tokens.text },
|
||||||
@@ -217,13 +228,21 @@ export const boldStyles = (
|
|||||||
},
|
},
|
||||||
cardRow: {
|
cardRow: {
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: "1fr auto",
|
alignItems: { xs: "start", md: "center" },
|
||||||
alignItems: "center",
|
gridTemplateColumns: { xs: "minmax(0, 1fr)", md: "1fr auto" },
|
||||||
gap: "24px",
|
gridTemplateAreas: {
|
||||||
|
xs: `"name" "status" "meta"`,
|
||||||
|
md: `"name name" "meta status"`,
|
||||||
|
},
|
||||||
|
columnGap: { md: "24px" },
|
||||||
|
rowGap: { xs: "10px", md: "6px" },
|
||||||
p: "22px 28px",
|
p: "22px 28px",
|
||||||
},
|
},
|
||||||
cardLeft: { minWidth: 0 },
|
cardLeft: { minWidth: 0, flex: 1, width: { xs: "100%", md: "auto" } },
|
||||||
monitorName: {
|
monitorName: {
|
||||||
|
gridArea: "name",
|
||||||
|
minWidth: 0,
|
||||||
|
width: { xs: "100%", md: "auto" },
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
fontSize: 17,
|
fontSize: 17,
|
||||||
letterSpacing: "-0.01em",
|
letterSpacing: "-0.01em",
|
||||||
@@ -233,10 +252,9 @@ export const boldStyles = (
|
|||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
},
|
},
|
||||||
monitorMeta: {
|
monitorMeta: {
|
||||||
display: "flex",
|
gridArea: "meta",
|
||||||
gap: "10px",
|
gap: "10px",
|
||||||
alignItems: "center",
|
alignItems: { xs: "flex-start", md: "center" },
|
||||||
mt: "6px",
|
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
},
|
},
|
||||||
pill: {
|
pill: {
|
||||||
@@ -273,6 +291,8 @@ export const boldStyles = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
badge: (tone) => ({
|
badge: (tone) => ({
|
||||||
|
gridArea: "status",
|
||||||
|
justifySelf: "start",
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
fontWeight: 800,
|
fontWeight: 800,
|
||||||
padding: "6px 14px",
|
padding: "6px 14px",
|
||||||
@@ -296,10 +316,10 @@ export const boldStyles = (
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
heatmap: {
|
heatmap: {
|
||||||
padding: "0 28px 22px",
|
padding: { xs: "0 12px 18px", md: "0 28px 22px" },
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
||||||
gap: "3px",
|
gap: { xs: "1px", md: "3px" },
|
||||||
height: 48,
|
height: 48,
|
||||||
},
|
},
|
||||||
heatmapCell: (kind) => ({
|
heatmapCell: (kind) => ({
|
||||||
@@ -312,10 +332,10 @@ export const boldStyles = (
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
histogram: {
|
histogram: {
|
||||||
padding: "0 28px",
|
padding: { xs: "0 12px", md: "0 28px" },
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
||||||
gap: "3px",
|
gap: { xs: "1px", md: "3px" },
|
||||||
alignItems: "flex-end",
|
alignItems: "flex-end",
|
||||||
height: 48,
|
height: 48,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ export const editorialStyles = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
top: {
|
top: {
|
||||||
display: "flex",
|
alignItems: { xs: "flex-start", md: "flex-end" },
|
||||||
alignItems: "flex-end",
|
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
|
gap: "12px",
|
||||||
mb: "48px",
|
mb: "48px",
|
||||||
borderBottom: `2px solid ${tokens.text}`,
|
borderBottom: `2px solid ${tokens.text}`,
|
||||||
pb: "18px",
|
pb: "18px",
|
||||||
@@ -119,7 +119,7 @@ export const editorialStyles = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
statusLine: {
|
statusLine: {
|
||||||
fontSize: 22,
|
fontSize: { xs: 18, md: 22 },
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
m: 0,
|
m: 0,
|
||||||
mb: "8px",
|
mb: "8px",
|
||||||
@@ -144,26 +144,32 @@ export const editorialStyles = (
|
|||||||
letterSpacing: "0.12em",
|
letterSpacing: "0.12em",
|
||||||
color: tokens.textMuted,
|
color: tokens.textMuted,
|
||||||
m: 0,
|
m: 0,
|
||||||
mb: "56px",
|
mb: { xs: "32px", md: "56px" },
|
||||||
},
|
},
|
||||||
|
|
||||||
chartSwitchWrap: {
|
chartSwitchWrap: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "flex-end",
|
justifyContent: { xs: "center", md: "flex-end" },
|
||||||
mb: "20px",
|
mb: "20px",
|
||||||
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
},
|
},
|
||||||
chartSwitch: {
|
chartSwitch: {
|
||||||
display: "inline-flex",
|
display: "inline-flex",
|
||||||
|
width: { xs: "100%", md: "auto" },
|
||||||
|
maxWidth: "100%",
|
||||||
border: `1px solid ${tokens.text}`,
|
border: `1px solid ${tokens.text}`,
|
||||||
"& > button + button": { borderLeft: `1px solid ${tokens.text}` },
|
"& > button + button": { borderLeft: `1px solid ${tokens.text}` },
|
||||||
},
|
},
|
||||||
chartSwitchButton: (active) => ({
|
chartSwitchButton: (active) => ({
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 0,
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
textAlign: "center",
|
||||||
fontFamily: "inherit",
|
fontFamily: "inherit",
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
textTransform: "uppercase",
|
textTransform: "uppercase",
|
||||||
letterSpacing: "0.2em",
|
letterSpacing: { xs: "0.05em", md: "0.2em" },
|
||||||
padding: "6px 14px",
|
padding: { xs: "6px 6px", md: "6px 14px" },
|
||||||
border: 0,
|
border: 0,
|
||||||
background: active ? tokens.text : "transparent",
|
background: active ? tokens.text : "transparent",
|
||||||
color: active ? tokens.bg : tokens.text,
|
color: active ? tokens.bg : tokens.text,
|
||||||
@@ -188,12 +194,20 @@ export const editorialStyles = (
|
|||||||
},
|
},
|
||||||
cardRow: {
|
cardRow: {
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: "1fr auto",
|
alignItems: { xs: "start", md: "baseline" },
|
||||||
alignItems: "baseline",
|
gridTemplateColumns: { xs: "minmax(0, 1fr)", md: "1fr auto" },
|
||||||
gap: "20px",
|
gridTemplateAreas: {
|
||||||
|
xs: `"name" "status" "meta"`,
|
||||||
|
md: `"name name" "meta status"`,
|
||||||
|
},
|
||||||
|
columnGap: { md: "20px" },
|
||||||
|
rowGap: { xs: "10px", md: "6px" },
|
||||||
},
|
},
|
||||||
cardLeft: { minWidth: 0 },
|
cardLeft: { minWidth: 0, flex: 1, width: { xs: "100%", md: "auto" } },
|
||||||
monitorName: {
|
monitorName: {
|
||||||
|
gridArea: "name",
|
||||||
|
minWidth: 0,
|
||||||
|
width: { xs: "100%", md: "auto" },
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
letterSpacing: "-0.015em",
|
letterSpacing: "-0.015em",
|
||||||
@@ -203,14 +217,13 @@ export const editorialStyles = (
|
|||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
},
|
},
|
||||||
monitorMeta: {
|
monitorMeta: {
|
||||||
|
gridArea: "meta",
|
||||||
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: tokens.textMuted,
|
color: tokens.textMuted,
|
||||||
mt: "6px",
|
|
||||||
display: "flex",
|
|
||||||
gap: "12px",
|
gap: "12px",
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
alignItems: "center",
|
alignItems: { xs: "flex-start", md: "center" },
|
||||||
},
|
},
|
||||||
pill: {
|
pill: {
|
||||||
textTransform: "uppercase",
|
textTransform: "uppercase",
|
||||||
@@ -234,6 +247,8 @@ export const editorialStyles = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
badge: (tone) => ({
|
badge: (tone) => ({
|
||||||
|
gridArea: "status",
|
||||||
|
justifySelf: "start",
|
||||||
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
@@ -250,7 +265,7 @@ export const editorialStyles = (
|
|||||||
mt: "16px",
|
mt: "16px",
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
||||||
gap: "2px",
|
gap: { xs: "1px", md: "2px" },
|
||||||
height: 40,
|
height: 40,
|
||||||
},
|
},
|
||||||
heatmapCell: (kind) => ({
|
heatmapCell: (kind) => ({
|
||||||
@@ -262,7 +277,7 @@ export const editorialStyles = (
|
|||||||
mt: "16px",
|
mt: "16px",
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
||||||
gap: "2px",
|
gap: { xs: "1px", md: "2px" },
|
||||||
alignItems: "flex-end",
|
alignItems: "flex-end",
|
||||||
height: 40,
|
height: 40,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,24 +11,24 @@ export const ModernHero = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<Box sx={styles.hero}>
|
<Box sx={styles.hero}>
|
||||||
<Box sx={styles.pulse(overall.tone)} />
|
<Box sx={styles.heroRow}>
|
||||||
<Box sx={styles.statusCopy}>
|
<Box sx={styles.pulse(overall.tone)} />
|
||||||
<Box
|
<Box
|
||||||
component="h1"
|
component="h1"
|
||||||
sx={styles.heroTitle}
|
sx={styles.heroTitle}
|
||||||
>
|
>
|
||||||
{overall.message}
|
{overall.message}
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box sx={styles.heroIcon(overall.tone)}>{overall.icon}</Box>
|
||||||
component="p"
|
</Box>
|
||||||
sx={styles.heroSub}
|
<Box
|
||||||
>
|
component="p"
|
||||||
{t("pages.statusPages.statusBar.monitoringSummary", {
|
sx={styles.heroSub}
|
||||||
count: monitorCount,
|
>
|
||||||
})}
|
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||||
</Box>
|
count: monitorCount,
|
||||||
|
})}
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={styles.heroIcon(overall.tone)}>{overall.icon}</Box>
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -17,7 +17,7 @@ export interface ModernStyles {
|
|||||||
logoImg: SxProps<Theme>;
|
logoImg: SxProps<Theme>;
|
||||||
hero: SxProps<Theme>;
|
hero: SxProps<Theme>;
|
||||||
pulse: (tone: OverallTone) => SxProps<Theme>;
|
pulse: (tone: OverallTone) => SxProps<Theme>;
|
||||||
statusCopy: SxProps<Theme>;
|
heroRow: SxProps<Theme>;
|
||||||
heroTitle: SxProps<Theme>;
|
heroTitle: SxProps<Theme>;
|
||||||
heroSub: SxProps<Theme>;
|
heroSub: SxProps<Theme>;
|
||||||
heroIcon: (tone: OverallTone) => SxProps<Theme>;
|
heroIcon: (tone: OverallTone) => SxProps<Theme>;
|
||||||
@@ -117,9 +117,9 @@ export const modernStyles = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
top: {
|
top: {
|
||||||
display: "flex",
|
alignItems: { xs: "flex-start", md: "center" },
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
|
gap: "12px",
|
||||||
mb: "32px",
|
mb: "32px",
|
||||||
},
|
},
|
||||||
brand: {
|
brand: {
|
||||||
@@ -148,11 +148,11 @@ export const modernStyles = (
|
|||||||
hero: {
|
hero: {
|
||||||
position: "relative",
|
position: "relative",
|
||||||
borderRadius: "20px",
|
borderRadius: "20px",
|
||||||
padding: "28px 32px",
|
padding: { xs: "20px", md: "28px 32px" },
|
||||||
mb: "24px",
|
mb: "24px",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
flexDirection: "column",
|
||||||
gap: "20px",
|
gap: "4px",
|
||||||
background: tokens.surface,
|
background: tokens.surface,
|
||||||
border: `1px solid ${tokens.border}`,
|
border: `1px solid ${tokens.border}`,
|
||||||
boxShadow: cardShadow,
|
boxShadow: cardShadow,
|
||||||
@@ -182,25 +182,37 @@ export const modernStyles = (
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
statusCopy: { flex: 1, minWidth: 0 },
|
heroRow: {
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: { xs: "14px", md: "20px" },
|
||||||
|
},
|
||||||
heroTitle: {
|
heroTitle: {
|
||||||
m: 0,
|
m: 0,
|
||||||
mb: "4px",
|
flex: 1,
|
||||||
fontSize: 22,
|
minWidth: 0,
|
||||||
|
fontSize: { xs: 18, md: 22 },
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
letterSpacing: "-0.02em",
|
letterSpacing: "-0.02em",
|
||||||
color: tokens.text,
|
color: tokens.text,
|
||||||
},
|
},
|
||||||
heroSub: { m: 0, color: tokens.textMuted, fontSize: 13 },
|
heroSub: { m: 0, color: tokens.textMuted, fontSize: 13 },
|
||||||
heroIcon: (tone) => ({
|
heroIcon: (tone) => ({
|
||||||
|
display: { xs: "none", md: "flex" },
|
||||||
color: toneColor(tone, tokens),
|
color: toneColor(tone, tokens),
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
flexShrink: 0,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
chartSwitchWrap: { display: "flex", justifyContent: "flex-end", mb: "14px" },
|
chartSwitchWrap: {
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: { xs: "center", md: "flex-end" },
|
||||||
|
mb: "14px",
|
||||||
|
},
|
||||||
chartSwitch: {
|
chartSwitch: {
|
||||||
display: "inline-flex",
|
display: "inline-flex",
|
||||||
|
width: { xs: "100%", md: "auto" },
|
||||||
|
maxWidth: "100%",
|
||||||
border: `1px solid ${tokens.border}`,
|
border: `1px solid ${tokens.border}`,
|
||||||
borderRadius: "999px",
|
borderRadius: "999px",
|
||||||
background: tokens.surface,
|
background: tokens.surface,
|
||||||
@@ -208,16 +220,20 @@ export const modernStyles = (
|
|||||||
gap: "2px",
|
gap: "2px",
|
||||||
},
|
},
|
||||||
chartSwitchButton: (active) => ({
|
chartSwitchButton: (active) => ({
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 0,
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
textAlign: "center",
|
||||||
border: 0,
|
border: 0,
|
||||||
background: active ? tokens.upSoft : "transparent",
|
background: active ? tokens.upSoft : "transparent",
|
||||||
fontFamily: "inherit",
|
fontFamily: "inherit",
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
padding: "6px 16px",
|
padding: { xs: "6px 6px", md: "6px 16px" },
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
color: active ? tokens.up : tokens.textMuted,
|
color: active ? tokens.up : tokens.textMuted,
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
textTransform: "uppercase",
|
textTransform: "uppercase",
|
||||||
letterSpacing: "0.08em",
|
letterSpacing: { xs: "0.04em", md: "0.08em" },
|
||||||
transition: "background 0.2s, color 0.2s",
|
transition: "background 0.2s, color 0.2s",
|
||||||
borderRadius: "999px",
|
borderRadius: "999px",
|
||||||
"&:hover": { color: active ? tokens.up : tokens.text },
|
"&:hover": { color: active ? tokens.up : tokens.text },
|
||||||
@@ -256,13 +272,21 @@ export const modernStyles = (
|
|||||||
},
|
},
|
||||||
cardRow: {
|
cardRow: {
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: "1fr auto",
|
alignItems: { xs: "start", md: "center" },
|
||||||
alignItems: "center",
|
gridTemplateColumns: { xs: "minmax(0, 1fr)", md: "1fr auto" },
|
||||||
gap: "20px",
|
gridTemplateAreas: {
|
||||||
|
xs: `"name" "status" "meta"`,
|
||||||
|
md: `"name name" "meta status"`,
|
||||||
|
},
|
||||||
|
columnGap: { md: "20px" },
|
||||||
|
rowGap: { xs: "10px", md: "6px" },
|
||||||
p: "18px 24px",
|
p: "18px 24px",
|
||||||
},
|
},
|
||||||
cardLeft: { minWidth: 0 },
|
cardLeft: { minWidth: 0, flex: 1, width: { xs: "100%", md: "auto" } },
|
||||||
monitorName: {
|
monitorName: {
|
||||||
|
gridArea: "name",
|
||||||
|
minWidth: 0,
|
||||||
|
width: { xs: "100%", md: "auto" },
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
letterSpacing: "-0.005em",
|
letterSpacing: "-0.005em",
|
||||||
@@ -272,10 +296,9 @@ export const modernStyles = (
|
|||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
},
|
},
|
||||||
monitorMeta: {
|
monitorMeta: {
|
||||||
display: "flex",
|
gridArea: "meta",
|
||||||
gap: "10px",
|
gap: "10px",
|
||||||
alignItems: "center",
|
alignItems: { xs: "flex-start", md: "center" },
|
||||||
mt: "6px",
|
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
},
|
},
|
||||||
pill: {
|
pill: {
|
||||||
@@ -299,6 +322,8 @@ export const modernStyles = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
badge: (tone) => ({
|
badge: (tone) => ({
|
||||||
|
gridArea: "status",
|
||||||
|
justifySelf: "start",
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
padding: "5px 12px",
|
padding: "5px 12px",
|
||||||
@@ -319,10 +344,10 @@ export const modernStyles = (
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
heatmap: {
|
heatmap: {
|
||||||
padding: "0 24px 20px",
|
padding: { xs: "0 12px 16px", md: "0 24px 20px" },
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
||||||
gap: "3px",
|
gap: { xs: "1px", md: "3px" },
|
||||||
height: 46,
|
height: 46,
|
||||||
},
|
},
|
||||||
heatmapCell: (kind) => ({
|
heatmapCell: (kind) => ({
|
||||||
@@ -334,10 +359,10 @@ export const modernStyles = (
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
histogram: {
|
histogram: {
|
||||||
padding: "0 24px",
|
padding: { xs: "0 12px", md: "0 24px" },
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
||||||
gap: "3px",
|
gap: { xs: "1px", md: "3px" },
|
||||||
alignItems: "flex-end",
|
alignItems: "flex-end",
|
||||||
height: 46,
|
height: 46,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,24 +11,24 @@ export const RefinedHero = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<Box sx={styles.hero}>
|
<Box sx={styles.hero}>
|
||||||
<Box sx={styles.statusDot(overall.tone)} />
|
<Box sx={styles.heroRow}>
|
||||||
<Box sx={styles.statusCopy}>
|
<Box sx={styles.statusDot(overall.tone)} />
|
||||||
<Box
|
<Box
|
||||||
component="h1"
|
component="h1"
|
||||||
sx={styles.heroTitle}
|
sx={styles.heroTitle}
|
||||||
>
|
>
|
||||||
{overall.message}
|
{overall.message}
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box sx={styles.heroIcon(overall.tone)}>{overall.icon}</Box>
|
||||||
component="p"
|
</Box>
|
||||||
sx={styles.heroSub}
|
<Box
|
||||||
>
|
component="p"
|
||||||
{t("pages.statusPages.statusBar.monitoringSummary", {
|
sx={styles.heroSub}
|
||||||
count: monitorCount,
|
>
|
||||||
})}
|
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||||
</Box>
|
count: monitorCount,
|
||||||
|
})}
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={styles.heroIcon(overall.tone)}>{overall.icon}</Box>
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -17,7 +17,7 @@ export interface RefinedStyles {
|
|||||||
company: SxProps<Theme>;
|
company: SxProps<Theme>;
|
||||||
hero: SxProps<Theme>;
|
hero: SxProps<Theme>;
|
||||||
statusDot: (tone: OverallTone) => SxProps<Theme>;
|
statusDot: (tone: OverallTone) => SxProps<Theme>;
|
||||||
statusCopy: SxProps<Theme>;
|
heroRow: SxProps<Theme>;
|
||||||
heroTitle: SxProps<Theme>;
|
heroTitle: SxProps<Theme>;
|
||||||
heroSub: SxProps<Theme>;
|
heroSub: SxProps<Theme>;
|
||||||
heroIcon: (tone: OverallTone) => SxProps<Theme>;
|
heroIcon: (tone: OverallTone) => SxProps<Theme>;
|
||||||
@@ -102,9 +102,9 @@ export const refinedStyles = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
top: {
|
top: {
|
||||||
display: "flex",
|
alignItems: { xs: "flex-start", md: "center" },
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
|
gap: "12px",
|
||||||
mb: "28px",
|
mb: "28px",
|
||||||
},
|
},
|
||||||
brand: {
|
brand: {
|
||||||
@@ -133,10 +133,10 @@ export const refinedStyles = (
|
|||||||
background: tokens.surface,
|
background: tokens.surface,
|
||||||
border: `1px solid ${tokens.border}`,
|
border: `1px solid ${tokens.border}`,
|
||||||
borderRadius: tokens.radius,
|
borderRadius: tokens.radius,
|
||||||
padding: "22px 24px",
|
padding: { xs: "18px 20px", md: "22px 24px" },
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
flexDirection: "column",
|
||||||
gap: "16px",
|
gap: "4px",
|
||||||
boxShadow: cardShadow,
|
boxShadow: cardShadow,
|
||||||
mb: "20px",
|
mb: "20px",
|
||||||
},
|
},
|
||||||
@@ -148,10 +148,15 @@ export const refinedStyles = (
|
|||||||
boxShadow: `0 0 0 4px ${toneSoft(tone, tokens)}`,
|
boxShadow: `0 0 0 4px ${toneSoft(tone, tokens)}`,
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
}),
|
}),
|
||||||
statusCopy: { flex: 1, minWidth: 0 },
|
heroRow: {
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: { xs: "12px", md: "16px" },
|
||||||
|
},
|
||||||
heroTitle: {
|
heroTitle: {
|
||||||
m: 0,
|
m: 0,
|
||||||
mb: "2px",
|
flex: 1,
|
||||||
|
minWidth: 0,
|
||||||
fontSize: 17,
|
fontSize: 17,
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
letterSpacing: "-0.01em",
|
letterSpacing: "-0.01em",
|
||||||
@@ -159,14 +164,21 @@ export const refinedStyles = (
|
|||||||
},
|
},
|
||||||
heroSub: { m: 0, color: tokens.textMuted, fontSize: 13 },
|
heroSub: { m: 0, color: tokens.textMuted, fontSize: 13 },
|
||||||
heroIcon: (tone) => ({
|
heroIcon: (tone) => ({
|
||||||
|
display: { xs: "none", md: "flex" },
|
||||||
color: toneColor(tone, tokens),
|
color: toneColor(tone, tokens),
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
flexShrink: 0,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
chartSwitchWrap: { display: "flex", justifyContent: "flex-end", mb: "12px" },
|
chartSwitchWrap: {
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: { xs: "center", md: "flex-end" },
|
||||||
|
mb: "12px",
|
||||||
|
},
|
||||||
chartSwitch: {
|
chartSwitch: {
|
||||||
display: "inline-flex",
|
display: "inline-flex",
|
||||||
|
width: { xs: "100%", md: "auto" },
|
||||||
|
maxWidth: "100%",
|
||||||
border: `1px solid ${tokens.border}`,
|
border: `1px solid ${tokens.border}`,
|
||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
background: tokens.surface,
|
background: tokens.surface,
|
||||||
@@ -174,11 +186,15 @@ export const refinedStyles = (
|
|||||||
gap: "2px",
|
gap: "2px",
|
||||||
},
|
},
|
||||||
chartSwitchButton: (active) => ({
|
chartSwitchButton: (active) => ({
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 0,
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
textAlign: "center",
|
||||||
border: 0,
|
border: 0,
|
||||||
background: active ? tokens.upSoft : "transparent",
|
background: active ? tokens.upSoft : "transparent",
|
||||||
fontFamily: "inherit",
|
fontFamily: "inherit",
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
padding: "5px 14px",
|
padding: { xs: "5px 6px", md: "5px 14px" },
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
color: active ? tokens.up : tokens.textMuted,
|
color: active ? tokens.up : tokens.textMuted,
|
||||||
borderRadius: "5px",
|
borderRadius: "5px",
|
||||||
@@ -207,13 +223,21 @@ export const refinedStyles = (
|
|||||||
},
|
},
|
||||||
cardRow: {
|
cardRow: {
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: "1fr auto",
|
alignItems: { xs: "start", md: "center" },
|
||||||
alignItems: "center",
|
gridTemplateColumns: { xs: "minmax(0, 1fr)", md: "1fr auto" },
|
||||||
gap: "16px",
|
gridTemplateAreas: {
|
||||||
|
xs: `"name" "status" "meta"`,
|
||||||
|
md: `"name name" "meta status"`,
|
||||||
|
},
|
||||||
|
columnGap: { md: "16px" },
|
||||||
|
rowGap: { xs: "10px", md: "4px" },
|
||||||
p: "16px 20px",
|
p: "16px 20px",
|
||||||
},
|
},
|
||||||
cardLeft: { minWidth: 0 },
|
cardLeft: { minWidth: 0, flex: 1, width: { xs: "100%", md: "auto" } },
|
||||||
monitorName: {
|
monitorName: {
|
||||||
|
gridArea: "name",
|
||||||
|
minWidth: 0,
|
||||||
|
width: { xs: "100%", md: "auto" },
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
letterSpacing: "-0.005em",
|
letterSpacing: "-0.005em",
|
||||||
@@ -223,10 +247,9 @@ export const refinedStyles = (
|
|||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
},
|
},
|
||||||
monitorMeta: {
|
monitorMeta: {
|
||||||
display: "flex",
|
gridArea: "meta",
|
||||||
gap: "10px",
|
gap: "10px",
|
||||||
alignItems: "center",
|
alignItems: { xs: "flex-start", md: "center" },
|
||||||
mt: "4px",
|
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
},
|
},
|
||||||
pill: {
|
pill: {
|
||||||
@@ -251,6 +274,8 @@ export const refinedStyles = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
badge: (tone) => ({
|
badge: (tone) => ({
|
||||||
|
gridArea: "status",
|
||||||
|
justifySelf: "start",
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
padding: "4px 10px",
|
padding: "4px 10px",
|
||||||
@@ -261,10 +286,10 @@ export const refinedStyles = (
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
heatmap: {
|
heatmap: {
|
||||||
padding: "0 20px 16px",
|
padding: { xs: "0 10px 14px", md: "0 20px 16px" },
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
||||||
gap: "3px",
|
gap: { xs: "1px", md: "3px" },
|
||||||
height: 42,
|
height: 42,
|
||||||
},
|
},
|
||||||
heatmapCell: (kind) => ({
|
heatmapCell: (kind) => ({
|
||||||
@@ -276,10 +301,10 @@ export const refinedStyles = (
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
histogram: {
|
histogram: {
|
||||||
padding: "0 20px",
|
padding: { xs: "0 10px", md: "0 20px" },
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`,
|
||||||
gap: "3px",
|
gap: { xs: "1px", md: "3px" },
|
||||||
alignItems: "flex-end",
|
alignItems: "flex-end",
|
||||||
height: 42,
|
height: 42,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import {
|
|||||||
statusBadgeKey,
|
statusBadgeKey,
|
||||||
} from "@/Pages/StatusPage/Status/themes/shared/overallStatus";
|
} from "@/Pages/StatusPage/Status/themes/shared/overallStatus";
|
||||||
import { useStatusPageTheme } from "@/Pages/StatusPage/Status/themes/StatusPageThemeProvider";
|
import { useStatusPageTheme } from "@/Pages/StatusPage/Status/themes/StatusPageThemeProvider";
|
||||||
|
import { formatPercentage } from "@/Utils/FormatUtils";
|
||||||
|
|
||||||
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
||||||
|
|
||||||
@@ -101,8 +102,9 @@ export const BaseStatusPage = ({ statusPage, monitors, config }: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={styles.page}>
|
<Box sx={styles.page}>
|
||||||
<Box
|
<Stack
|
||||||
component="header"
|
component="header"
|
||||||
|
direction={{ xs: "column", md: "row" }}
|
||||||
sx={styles.top}
|
sx={styles.top}
|
||||||
>
|
>
|
||||||
<HeaderSlot
|
<HeaderSlot
|
||||||
@@ -112,7 +114,7 @@ export const BaseStatusPage = ({ statusPage, monitors, config }: Props) => {
|
|||||||
monitorCount={monitors.length}
|
monitorCount={monitors.length}
|
||||||
styles={styles}
|
styles={styles}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Stack>
|
||||||
|
|
||||||
<HeroSlot
|
<HeroSlot
|
||||||
statusPage={statusPage}
|
statusPage={statusPage}
|
||||||
@@ -161,6 +163,7 @@ export const BaseStatusPage = ({ statusPage, monitors, config }: Props) => {
|
|||||||
const showInfra = isHardware && statusPage.showInfrastructure !== false;
|
const showInfra = isHardware && statusPage.showInfrastructure !== false;
|
||||||
const showChart = !isHardware && statusPage.showCharts !== false;
|
const showChart = !isHardware && statusPage.showCharts !== false;
|
||||||
const badgeTone = monitorBadgeTone(monitor.status);
|
const badgeTone = monitorBadgeTone(monitor.status);
|
||||||
|
const uptimePercentage = formatPercentage(monitor.uptimePercentage ?? 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -169,32 +172,39 @@ export const BaseStatusPage = ({ statusPage, monitors, config }: Props) => {
|
|||||||
sx={styles.card}
|
sx={styles.card}
|
||||||
>
|
>
|
||||||
<Box sx={styles.cardRow}>
|
<Box sx={styles.cardRow}>
|
||||||
<Box sx={styles.cardLeft}>
|
<Box sx={styles.monitorName}>{monitor.name}</Box>
|
||||||
<Box sx={styles.monitorName}>{monitor.name}</Box>
|
|
||||||
<Box sx={styles.monitorMeta}>
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={isHardware ? styles.pillHardware : styles.pill}
|
|
||||||
>
|
|
||||||
{getMonitorTypeLabel(monitor.type, t)}
|
|
||||||
</Box>
|
|
||||||
{monitor.url && (
|
|
||||||
<Box
|
|
||||||
component="span"
|
|
||||||
sx={styles.monitorUrl}
|
|
||||||
title={monitor.url}
|
|
||||||
>
|
|
||||||
{monitor.url}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<Box
|
<Box
|
||||||
component="span"
|
component="span"
|
||||||
sx={styles.badge(badgeTone)}
|
sx={styles.badge(badgeTone)}
|
||||||
>
|
>
|
||||||
{t(statusBadgeKey[monitor.status])}
|
{t(statusBadgeKey[monitor.status])}
|
||||||
</Box>
|
</Box>
|
||||||
|
<Stack
|
||||||
|
direction={{ xs: "column", md: "row" }}
|
||||||
|
sx={styles.monitorMeta}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={isHardware ? styles.pillHardware : styles.pill}
|
||||||
|
>
|
||||||
|
{getMonitorTypeLabel(monitor.type, t)}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={{ ...styles.pill }}
|
||||||
|
>
|
||||||
|
{uptimePercentage}
|
||||||
|
</Box>
|
||||||
|
{monitor.url && (
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.monitorUrl}
|
||||||
|
title={monitor.url}
|
||||||
|
>
|
||||||
|
{monitor.url}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{showInfra && (
|
{showInfra && (
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { PUBLIC_STATUS_PAGE_PREFIX, type StatusPage } from "@/Types/StatusPage";
|
import { getStatusPagePublicPath, getStatusPagePublicUrl } from "@/Utils/statusPageUrl";
|
||||||
|
|
||||||
|
import { type StatusPage } from "@/Types/StatusPage";
|
||||||
|
|
||||||
interface StatusPagesTableProps {
|
interface StatusPagesTableProps {
|
||||||
data: StatusPage[];
|
data: StatusPage[];
|
||||||
@@ -53,8 +55,7 @@ export const StatusPagesTable = ({
|
|||||||
const handleUrlClick = (e: React.MouseEvent, row: StatusPage) => {
|
const handleUrlClick = (e: React.MouseEvent, row: StatusPage) => {
|
||||||
if (row.isPublished) {
|
if (row.isPublished) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const url = `${PUBLIC_STATUS_PAGE_PREFIX}/${row.url}`;
|
window.open(getStatusPagePublicUrl(row), "_blank", "noopener,noreferrer");
|
||||||
window.open(url, "_blank", "noopener,noreferrer");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,7 +71,9 @@ export const StatusPagesTable = ({
|
|||||||
content: t("pages.statusPages.table.headers.url"),
|
content: t("pages.statusPages.table.headers.url"),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
const content = row.isPublished
|
const content = row.isPublished
|
||||||
? `/${row.url}`
|
? row.customDomain
|
||||||
|
? getStatusPagePublicPath(row)
|
||||||
|
: `/${row.url}`
|
||||||
: t("pages.statusPages.table.unpublished");
|
: t("pages.statusPages.table.unpublished");
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import type { RootState } from "@/Types/state";
|
|||||||
import { Checkbox } from "@/Components/inputs";
|
import { Checkbox } from "@/Components/inputs";
|
||||||
import type { Tag } from "@/Types/Tag";
|
import type { Tag } from "@/Types/Tag";
|
||||||
import { SPACING } from "@/Utils/Theme/constants";
|
import { SPACING } from "@/Utils/Theme/constants";
|
||||||
|
import { getUptimePercentageColor } from "@/Utils/MonitorUtils";
|
||||||
|
import { formatPercentage } from "@/Utils/FormatUtils";
|
||||||
|
|
||||||
interface MonitorTableProps {
|
interface MonitorTableProps {
|
||||||
monitors: Monitor[];
|
monitors: Monitor[];
|
||||||
@@ -259,6 +261,24 @@ export const MonitorTable = ({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "uptime",
|
||||||
|
content: t("pages.uptime.table.headers.uptime"),
|
||||||
|
render: (row) => {
|
||||||
|
const uptimePercentage = row.uptimePercentage ?? 0;
|
||||||
|
const formattedPercentage = formatPercentage(uptimePercentage);
|
||||||
|
const paletteKey = getUptimePercentageColor(uptimePercentage);
|
||||||
|
const color = theme.palette[paletteKey].main;
|
||||||
|
return (
|
||||||
|
<Stack alignItems={"center"}>
|
||||||
|
<ColoredLabel
|
||||||
|
text={formattedPercentage}
|
||||||
|
color={color}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "tags",
|
id: "tags",
|
||||||
content: t("common.table.headers.tags"),
|
content: t("common.table.headers.tags"),
|
||||||
@@ -304,7 +324,9 @@ export const MonitorTable = ({
|
|||||||
</Stack>
|
</Stack>
|
||||||
),
|
),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
return row.type;
|
return row.type === "http" && row.method
|
||||||
|
? `${row.type} (${row.method})`
|
||||||
|
: row.type;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,8 +54,24 @@ import Logs from "@/Pages/Logs";
|
|||||||
import { ProtectedRoute, RoleProtectedRoute } from "@/Components/routing/RouteProtected";
|
import { ProtectedRoute, RoleProtectedRoute } from "@/Components/routing/RouteProtected";
|
||||||
|
|
||||||
import CreateMonitor from "@/Pages/CreateMonitor";
|
import CreateMonitor from "@/Pages/CreateMonitor";
|
||||||
|
import { isCustomDomainHost } from "@/Utils/statusPageUrl";
|
||||||
|
|
||||||
const Routes = () => {
|
const Routes = () => {
|
||||||
|
if (isCustomDomainHost()) {
|
||||||
|
return (
|
||||||
|
<LibRoutes>
|
||||||
|
<Route
|
||||||
|
path="/"
|
||||||
|
element={<Status />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="*"
|
||||||
|
element={<Status />}
|
||||||
|
/>
|
||||||
|
</LibRoutes>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LibRoutes>
|
<LibRoutes>
|
||||||
<Route
|
<Route
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ export interface V8HeapStats {
|
|||||||
|
|
||||||
export interface MongoStats {
|
export interface MongoStats {
|
||||||
readyState: number;
|
readyState: number;
|
||||||
|
readsPerSecond: number;
|
||||||
|
insertsPerSecond: number;
|
||||||
|
updatesPerSecond: number;
|
||||||
|
deletesPerSecond: number;
|
||||||
|
writesPerSecond: number;
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
dbName: string;
|
dbName: string;
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ export const PageSpeedStrategies = ["desktop", "mobile"] as const;
|
|||||||
export type PageSpeedStrategy = (typeof PageSpeedStrategies)[number];
|
export type PageSpeedStrategy = (typeof PageSpeedStrategies)[number];
|
||||||
export const DefaultPageSpeedStrategy: PageSpeedStrategy = "desktop";
|
export const DefaultPageSpeedStrategy: PageSpeedStrategy = "desktop";
|
||||||
|
|
||||||
|
export const HttpMethods = ["GET", "HEAD"] as const;
|
||||||
|
export type HttpMethod = (typeof HttpMethods)[number];
|
||||||
|
export const DefaultHttpMethod: HttpMethod = "GET";
|
||||||
|
|
||||||
export interface Monitor {
|
export interface Monitor {
|
||||||
id: string;
|
id: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
@@ -64,6 +68,7 @@ export interface Monitor {
|
|||||||
jsonPath?: string;
|
jsonPath?: string;
|
||||||
expectedValue?: string;
|
expectedValue?: string;
|
||||||
matchMethod?: MonitorMatchMethod;
|
matchMethod?: MonitorMatchMethod;
|
||||||
|
method?: HttpMethod;
|
||||||
url: string;
|
url: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
@@ -71,6 +76,7 @@ export interface Monitor {
|
|||||||
uptimePercentage?: number;
|
uptimePercentage?: number;
|
||||||
notifications: string[];
|
notifications: string[];
|
||||||
tags: string[];
|
tags: string[];
|
||||||
|
customUpCodes?: number[];
|
||||||
secret?: string;
|
secret?: string;
|
||||||
cpuAlertThreshold: number;
|
cpuAlertThreshold: number;
|
||||||
cpuAlertCounter: number;
|
cpuAlertCounter: number;
|
||||||
|
|||||||
@@ -30,23 +30,16 @@ export type QueueMetrics = {
|
|||||||
|
|
||||||
export type QueueJobSummary = {
|
export type QueueJobSummary = {
|
||||||
monitorId: string | number;
|
monitorId: string | number;
|
||||||
monitorUrl: string | null;
|
|
||||||
monitorType: string | null;
|
monitorType: string | null;
|
||||||
monitorInterval: number | null;
|
monitorInterval: number | null;
|
||||||
monitorGeoInterval: number | null;
|
|
||||||
monitorActive: boolean | null;
|
monitorActive: boolean | null;
|
||||||
active: boolean;
|
|
||||||
lockedBy: string | null;
|
lockedBy: string | null;
|
||||||
lockedUntil: number | null;
|
lockedUntil: number | null;
|
||||||
lockedAt: number | null;
|
nextScheduledAt: number;
|
||||||
runCount: number;
|
runCount: number;
|
||||||
failCount: number;
|
failCount: number;
|
||||||
failReason: string | null;
|
failReason: string | null;
|
||||||
lastRunAt: number | null;
|
|
||||||
lastFinishedAt: number | null;
|
lastFinishedAt: number | null;
|
||||||
lastRunTook: number | null;
|
|
||||||
lastFailedAt: number | null;
|
|
||||||
repeat: number | null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface QueueData {
|
export interface QueueData {
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export interface StatusPage {
|
|||||||
type: MonitorDisplayType[];
|
type: MonitorDisplayType[];
|
||||||
companyName: string;
|
companyName: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
customDomain?: string | null;
|
||||||
timezone?: string;
|
timezone?: string;
|
||||||
color: string;
|
color: string;
|
||||||
monitors: string[];
|
monitors: string[];
|
||||||
|
|||||||
@@ -63,6 +63,16 @@ export const getResponseTimeColor = (responseTime: number): PaletteKey => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getUptimePercentageColor = (uptimePercentage: number): PaletteKey => {
|
||||||
|
if (uptimePercentage >= 0.75) {
|
||||||
|
return "success";
|
||||||
|
} else if (uptimePercentage >= 0.5) {
|
||||||
|
return "warning";
|
||||||
|
} else {
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const getInfraGaugeColor = (val: number, theme: any) => {
|
export const getInfraGaugeColor = (val: number, theme: any) => {
|
||||||
if (val < 50) {
|
if (val < 50) {
|
||||||
return theme.palette.success.main;
|
return theme.palette.success.main;
|
||||||
|
|||||||
@@ -74,3 +74,96 @@ export const getStatusCodeValueType = (code: number): ValueType => {
|
|||||||
if (code < 400) return "neutral";
|
if (code < 400) return "neutral";
|
||||||
return "negative";
|
return "negative";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface HttpStatusCodeOption {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must stay in sync with HttpStatusCodes in server/src/domain/monitors/monitor.types.ts
|
||||||
|
*/
|
||||||
|
export const ALL_HTTP_STATUS_CODES: HttpStatusCodeOption[] = [
|
||||||
|
{ id: 100, name: "100 - Continue" },
|
||||||
|
{ id: 101, name: "101 - Switching Protocols" },
|
||||||
|
{ id: 102, name: "102 - Processing" },
|
||||||
|
{ id: 103, name: "103 - Early Hints" },
|
||||||
|
{ id: 200, name: "200 - OK" },
|
||||||
|
{ id: 201, name: "201 - Created" },
|
||||||
|
{ id: 202, name: "202 - Accepted" },
|
||||||
|
{ id: 203, name: "203 - Non-Authoritative Information" },
|
||||||
|
{ id: 204, name: "204 - No Content" },
|
||||||
|
{ id: 205, name: "205 - Reset Content" },
|
||||||
|
{ id: 206, name: "206 - Partial Content" },
|
||||||
|
{ id: 207, name: "207 - Multi-Status" },
|
||||||
|
{ id: 208, name: "208 - Already Reported" },
|
||||||
|
{ id: 226, name: "226 - IM Used" },
|
||||||
|
{ id: 300, name: "300 - Multiple Choices" },
|
||||||
|
{ id: 301, name: "301 - Moved Permanently" },
|
||||||
|
{ id: 302, name: "302 - Found" },
|
||||||
|
{ id: 303, name: "303 - See Other" },
|
||||||
|
{ id: 304, name: "304 - Not Modified" },
|
||||||
|
{ id: 305, name: "305 - Use Proxy" },
|
||||||
|
{ id: 307, name: "307 - Temporary Redirect" },
|
||||||
|
{ id: 308, name: "308 - Permanent Redirect" },
|
||||||
|
{ id: 400, name: "400 - Bad Request" },
|
||||||
|
{ id: 401, name: "401 - Unauthorized" },
|
||||||
|
{ id: 402, name: "402 - Payment Required" },
|
||||||
|
{ id: 403, name: "403 - Forbidden" },
|
||||||
|
{ id: 404, name: "404 - Not Found" },
|
||||||
|
{ id: 405, name: "405 - Method Not Allowed" },
|
||||||
|
{ id: 406, name: "406 - Not Acceptable" },
|
||||||
|
{ id: 407, name: "407 - Proxy Authentication Required" },
|
||||||
|
{ id: 408, name: "408 - Request Timeout" },
|
||||||
|
{ id: 409, name: "409 - Conflict" },
|
||||||
|
{ id: 410, name: "410 - Gone" },
|
||||||
|
{ id: 411, name: "411 - Length Required" },
|
||||||
|
{ id: 412, name: "412 - Precondition Failed" },
|
||||||
|
{ id: 413, name: "413 - Payload Too Large" },
|
||||||
|
{ id: 414, name: "414 - URI Too Long" },
|
||||||
|
{ id: 415, name: "415 - Unsupported Media Type" },
|
||||||
|
{ id: 416, name: "416 - Range Not Satisfiable" },
|
||||||
|
{ id: 417, name: "417 - Expectation Failed" },
|
||||||
|
{ id: 418, name: "418 - I'm a Teapot" },
|
||||||
|
{ id: 419, name: "419 - Page Expired (Laravel)" },
|
||||||
|
{ id: 420, name: "420 - Enhance Your Calm (Twitter)" },
|
||||||
|
{ id: 421, name: "421 - Misdirected Request" },
|
||||||
|
{ id: 422, name: "422 - Unprocessable Entity" },
|
||||||
|
{ id: 423, name: "423 - Locked" },
|
||||||
|
{ id: 424, name: "424 - Failed Dependency" },
|
||||||
|
{ id: 425, name: "425 - Too Early" },
|
||||||
|
{ id: 426, name: "426 - Upgrade Required" },
|
||||||
|
{ id: 428, name: "428 - Precondition Required" },
|
||||||
|
{ id: 429, name: "429 - Too Many Requests" },
|
||||||
|
{ id: 431, name: "431 - Request Header Fields Too Large" },
|
||||||
|
{ id: 440, name: "440 - Login Time-out (IIS)" },
|
||||||
|
{ id: 449, name: "449 - Retry With (IIS)" },
|
||||||
|
{ id: 451, name: "451 - Unavailable For Legal Reasons" },
|
||||||
|
{ id: 460, name: "460 - Client Closed Connection (AWS ELB)" },
|
||||||
|
{ id: 463, name: "463 - X-Forwarded-For Too Large (AWS ELB)" },
|
||||||
|
{ id: 497, name: "497 - HTTP Request Sent to HTTPS Port (NGINX)" },
|
||||||
|
{ id: 499, name: "499 - Client Closed Request (NGINX)" },
|
||||||
|
{ id: 500, name: "500 - Internal Server Error" },
|
||||||
|
{ id: 501, name: "501 - Not Implemented" },
|
||||||
|
{ id: 502, name: "502 - Bad Gateway" },
|
||||||
|
{ id: 503, name: "503 - Service Unavailable" },
|
||||||
|
{ id: 504, name: "504 - Gateway Timeout" },
|
||||||
|
{ id: 505, name: "505 - HTTP Version Not Supported" },
|
||||||
|
{ id: 506, name: "506 - Variant Also Negotiates" },
|
||||||
|
{ id: 507, name: "507 - Insufficient Storage" },
|
||||||
|
{ id: 508, name: "508 - Loop Detected" },
|
||||||
|
{ id: 509, name: "509 - Bandwidth Limit Exceeded (Apache)" },
|
||||||
|
{ id: 510, name: "510 - Not Extended" },
|
||||||
|
{ id: 511, name: "511 - Network Authentication Required" },
|
||||||
|
{ id: 520, name: "520 - Web Server Returned an Unknown Error (Cloudflare)" },
|
||||||
|
{ id: 521, name: "521 - Web Server Is Down (Cloudflare)" },
|
||||||
|
{ id: 522, name: "522 - Connection Timed Out (Cloudflare)" },
|
||||||
|
{ id: 523, name: "523 - Origin Is Unreachable (Cloudflare)" },
|
||||||
|
{ id: 524, name: "524 - A Timeout Occurred (Cloudflare)" },
|
||||||
|
{ id: 525, name: "525 - SSL Handshake Failed (Cloudflare)" },
|
||||||
|
{ id: 526, name: "526 - Invalid SSL Certificate (Cloudflare)" },
|
||||||
|
{ id: 527, name: "527 - Railgun Error (Cloudflare)" },
|
||||||
|
{ id: 529, name: "529 - Site is overloaded" },
|
||||||
|
{ id: 530, name: "530 - Site is frozen (Cloudflare)" },
|
||||||
|
{ id: 561, name: "561 - Unauthorized (AWS ELB)" },
|
||||||
|
];
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
import { PUBLIC_STATUS_PAGE_PREFIX, type StatusPage } from "@/Types/StatusPage";
|
||||||
|
|
||||||
|
const CLIENT_HOST = import.meta.env.VITE_APP_CLIENT_HOST as string | undefined;
|
||||||
|
|
||||||
|
const getClientOriginProtocol = (): string => {
|
||||||
|
const source =
|
||||||
|
CLIENT_HOST || (typeof window !== "undefined" ? window.location.origin : undefined);
|
||||||
|
if (!source) {
|
||||||
|
return "https:";
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new URL(source).protocol;
|
||||||
|
} catch {
|
||||||
|
return "https:";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildCustomDomainOrigin = (customDomain: string): string =>
|
||||||
|
`${getClientOriginProtocol()}//${customDomain}`;
|
||||||
|
|
||||||
|
export const getAppHostname = (): string | null => {
|
||||||
|
const source =
|
||||||
|
CLIENT_HOST || (typeof window !== "undefined" ? window.location.origin : undefined);
|
||||||
|
if (!source) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new URL(source).hostname.toLowerCase();
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const isCustomDomainHost = (): boolean => {
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const appHostname = getAppHostname();
|
||||||
|
if (!appHostname) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return window.location.hostname.toLowerCase() !== appHostname;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStatusPagePublicPath = (
|
||||||
|
statusPage: Pick<StatusPage, "url" | "customDomain">
|
||||||
|
): string => {
|
||||||
|
if (statusPage.customDomain) {
|
||||||
|
return buildCustomDomainOrigin(statusPage.customDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${PUBLIC_STATUS_PAGE_PREFIX}/${statusPage.url}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStatusPagePublicUrl = (
|
||||||
|
statusPage: Pick<StatusPage, "url" | "customDomain">
|
||||||
|
): string => {
|
||||||
|
if (statusPage.customDomain) {
|
||||||
|
return buildCustomDomainOrigin(statusPage.customDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
return `${window.location.origin}${PUBLIC_STATUS_PAGE_PREFIX}/${statusPage.url}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${PUBLIC_STATUS_PAGE_PREFIX}/${statusPage.url}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const buildStatusPageApiPath = (options: {
|
||||||
|
url?: string;
|
||||||
|
useCustomDomain?: boolean;
|
||||||
|
}): string | null => {
|
||||||
|
const query = "type=uptime&type=infrastructure";
|
||||||
|
|
||||||
|
if (options.useCustomDomain && typeof window !== "undefined") {
|
||||||
|
const domain = encodeURIComponent(window.location.hostname);
|
||||||
|
return `/status-page/resolve?domain=${domain}&${query}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.url) {
|
||||||
|
return `/status-page/${options.url}?${query}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
@@ -1,7 +1,13 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import type { FieldPath } from "react-hook-form";
|
import type { FieldPath } from "react-hook-form";
|
||||||
import { GeoContinents } from "@/Types/GeoCheck";
|
import { GeoContinents } from "@/Types/GeoCheck";
|
||||||
import { DnsRecordTypes, PageSpeedStrategies, type MonitorType } from "@/Types/Monitor";
|
import {
|
||||||
|
DnsRecordTypes,
|
||||||
|
HttpMethods,
|
||||||
|
PageSpeedStrategies,
|
||||||
|
type MonitorType,
|
||||||
|
} from "@/Types/Monitor";
|
||||||
|
import { ALL_HTTP_STATUS_CODES } from "@/Utils/statusCode";
|
||||||
|
|
||||||
// Wizard step a field is validated on. Attached inline to each field below so
|
// Wizard step a field is validated on. Attached inline to each field below so
|
||||||
// the grouping lives next to the field definition; unannotated fields default
|
// the grouping lives next to the field definition; unannotated fields default
|
||||||
@@ -53,9 +59,15 @@ const geoCheckFields = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// HTTP monitor schema
|
// HTTP monitor schema
|
||||||
|
const httpStatusCodeSet = new Set(ALL_HTTP_STATUS_CODES.map((c) => c.id));
|
||||||
|
const httpStatusCode = z.number().refine((code) => httpStatusCodeSet.has(code), {
|
||||||
|
message: "Must be a valid HTTP status code",
|
||||||
|
});
|
||||||
|
|
||||||
const httpSchema = baseSchema.extend({
|
const httpSchema = baseSchema.extend({
|
||||||
type: z.literal("http"),
|
type: z.literal("http"),
|
||||||
url: urlSchema,
|
url: urlSchema,
|
||||||
|
method: z.enum(HttpMethods).optional().register(monitorStepRegistry, { step: 2 }),
|
||||||
ignoreTlsErrors: z.boolean().register(monitorStepRegistry, { step: 2 }),
|
ignoreTlsErrors: z.boolean().register(monitorStepRegistry, { step: 2 }),
|
||||||
useAdvancedMatching: z.boolean().register(monitorStepRegistry, { step: 2 }),
|
useAdvancedMatching: z.boolean().register(monitorStepRegistry, { step: 2 }),
|
||||||
matchMethod: z
|
matchMethod: z
|
||||||
@@ -64,6 +76,10 @@ const httpSchema = baseSchema.extend({
|
|||||||
.register(monitorStepRegistry, { step: 2 }),
|
.register(monitorStepRegistry, { step: 2 }),
|
||||||
expectedValue: z.string().optional().register(monitorStepRegistry, { step: 2 }),
|
expectedValue: z.string().optional().register(monitorStepRegistry, { step: 2 }),
|
||||||
jsonPath: z.string().optional().register(monitorStepRegistry, { step: 2 }),
|
jsonPath: z.string().optional().register(monitorStepRegistry, { step: 2 }),
|
||||||
|
customUpCodes: z
|
||||||
|
.array(httpStatusCode)
|
||||||
|
.optional()
|
||||||
|
.register(monitorStepRegistry, { step: 2 }),
|
||||||
...geoCheckFields,
|
...geoCheckFields,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,23 @@ import { STATUS_PAGE_THEMES, STATUS_PAGE_THEME_MODES } from "@/Types/StatusPage"
|
|||||||
// field definitions.
|
// field definitions.
|
||||||
export const statusPageStepRegistry = z.registry<{ step: number }>();
|
export const statusPageStepRegistry = z.registry<{ step: number }>();
|
||||||
|
|
||||||
|
const statusPageHostnameRegex =
|
||||||
|
/^(?=.{1,253}$)([a-zA-Z0-9_](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/;
|
||||||
|
|
||||||
|
const normalizeCustomDomainInput = (raw: string | null): string | null => {
|
||||||
|
if (raw === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const trimmed = raw.trim().toLowerCase();
|
||||||
|
if (!trimmed) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const withoutScheme = trimmed.replace(/^https?:\/\//, "");
|
||||||
|
return withoutScheme.split("/")[0]?.split(":")[0] ?? null;
|
||||||
|
};
|
||||||
|
|
||||||
export const statusPageSchema = z.object({
|
export const statusPageSchema = z.object({
|
||||||
companyName: z
|
companyName: z
|
||||||
.string()
|
.string()
|
||||||
@@ -22,6 +39,12 @@ export const statusPageSchema = z.object({
|
|||||||
/^[a-z0-9-]+$/,
|
/^[a-z0-9-]+$/,
|
||||||
"URL can only contain lowercase letters, numbers, and hyphens"
|
"URL can only contain lowercase letters, numbers, and hyphens"
|
||||||
),
|
),
|
||||||
|
customDomain: z
|
||||||
|
.union([z.string(), z.null()])
|
||||||
|
.transform(normalizeCustomDomainInput)
|
||||||
|
.refine((domain) => domain === null || statusPageHostnameRegex.test(domain), {
|
||||||
|
message: "Enter a valid domain name (e.g. status.example.com)",
|
||||||
|
}),
|
||||||
timezone: z.string().optional(),
|
timezone: z.string().optional(),
|
||||||
type: z
|
type: z
|
||||||
.array(z.enum(["uptime", "infrastructure"]))
|
.array(z.enum(["uptime", "infrastructure"]))
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "معرّف المراقب",
|
"monitorId": "معرّف المراقب",
|
||||||
"runCount": "عدد التشغيلات",
|
"runCount": "عدد التشغيلات",
|
||||||
"failCount": "عدد حالات الفشل",
|
"failCount": "عدد حالات الفشل",
|
||||||
"lastRunAt": "آخر تشغيل في",
|
|
||||||
"lockedAt": "مقفل في",
|
|
||||||
"lastFinishedAt": "آخر انتهاء في",
|
"lastFinishedAt": "آخر انتهاء في",
|
||||||
"lastRunTook": "مدة آخر تشغيل",
|
|
||||||
"lastFailedAt": "آخر فشل في",
|
"lastFailedAt": "آخر فشل في",
|
||||||
"failReason": "سبب الفشل",
|
"failReason": "سبب الفشل",
|
||||||
"state": "الحالة"
|
"state": "الحالة"
|
||||||
|
|||||||
@@ -945,10 +945,7 @@
|
|||||||
"monitorId": "ID del monitor",
|
"monitorId": "ID del monitor",
|
||||||
"runCount": "Recompte d'execucions",
|
"runCount": "Recompte d'execucions",
|
||||||
"failCount": "Recompte",
|
"failCount": "Recompte",
|
||||||
"lastRunAt": "Darrera execució",
|
|
||||||
"lockedAt": "Bloquejat el",
|
|
||||||
"lastFinishedAt": "Darrera finalització",
|
"lastFinishedAt": "Darrera finalització",
|
||||||
"lastRunTook": "Durada de la darrera execució",
|
|
||||||
"lastFailedAt": "Darrera fallada",
|
"lastFailedAt": "Darrera fallada",
|
||||||
"failReason": "Motiu de la fallada",
|
"failReason": "Motiu de la fallada",
|
||||||
"state": "Estat"
|
"state": "Estat"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "ID monitoru",
|
"monitorId": "ID monitoru",
|
||||||
"runCount": "Počet spuštění",
|
"runCount": "Počet spuštění",
|
||||||
"failCount": "Počet selhání",
|
"failCount": "Počet selhání",
|
||||||
"lastRunAt": "Poslední spuštění",
|
|
||||||
"lockedAt": "Uzamčeno v",
|
|
||||||
"lastFinishedAt": "Naposledy dokončeno",
|
"lastFinishedAt": "Naposledy dokončeno",
|
||||||
"lastRunTook": "Poslední běh trval",
|
|
||||||
"lastFailedAt": "Poslední selhání",
|
"lastFailedAt": "Poslední selhání",
|
||||||
"failReason": "Důvod selhání",
|
"failReason": "Důvod selhání",
|
||||||
"state": "Stav"
|
"state": "Stav"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "Monitor-ID",
|
"monitorId": "Monitor-ID",
|
||||||
"runCount": "Ausführungen",
|
"runCount": "Ausführungen",
|
||||||
"failCount": "Fehlerzahl",
|
"failCount": "Fehlerzahl",
|
||||||
"lastRunAt": "Letzter Lauf am",
|
|
||||||
"lockedAt": "Gesperrt am",
|
|
||||||
"lastFinishedAt": "Zuletzt abgeschlossen am",
|
"lastFinishedAt": "Zuletzt abgeschlossen am",
|
||||||
"lastRunTook": "Letzter Lauf dauerte",
|
|
||||||
"lastFailedAt": "Letzter Fehler am",
|
"lastFailedAt": "Letzter Fehler am",
|
||||||
"failReason": "Fehlergrund",
|
"failReason": "Fehlergrund",
|
||||||
"state": "Status"
|
"state": "Status"
|
||||||
|
|||||||
@@ -490,6 +490,13 @@
|
|||||||
"advanced": {
|
"advanced": {
|
||||||
"description": "Optional settings for advanced use cases",
|
"description": "Optional settings for advanced use cases",
|
||||||
"option": {
|
"option": {
|
||||||
|
"method": {
|
||||||
|
"label": "Request method",
|
||||||
|
"description": {
|
||||||
|
"GET": "GET fetches the full response including the body. Advanced matching fully supported",
|
||||||
|
"HEAD": "HEAD fetches only response headers for reducing load on the target. Supports status code matching but not advanced matching as there is no body."
|
||||||
|
}
|
||||||
|
},
|
||||||
"advancedMatching": {
|
"advancedMatching": {
|
||||||
"label": "Use advanced matching"
|
"label": "Use advanced matching"
|
||||||
},
|
},
|
||||||
@@ -505,6 +512,11 @@
|
|||||||
"equal": "Equal",
|
"equal": "Equal",
|
||||||
"include": "Include",
|
"include": "Include",
|
||||||
"regex": "Regex"
|
"regex": "Regex"
|
||||||
|
},
|
||||||
|
"customUpCodes": {
|
||||||
|
"label": "Accepted status codes",
|
||||||
|
"description": "Add any non-2xx codes that should also be considered successful.",
|
||||||
|
"removeAriaLabel": "Remove status code"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"title": "Advanced settings"
|
"title": "Advanced settings"
|
||||||
@@ -975,6 +987,11 @@
|
|||||||
},
|
},
|
||||||
"mongoDBStats": {
|
"mongoDBStats": {
|
||||||
"readyState": "Ready state",
|
"readyState": "Ready state",
|
||||||
|
"readsPerSecond": "Reads/s",
|
||||||
|
"insertsPerSecond": "Inserts/s",
|
||||||
|
"updatesPerSecond": "Updates/s",
|
||||||
|
"deletesPerSecond": "Deletes/s",
|
||||||
|
"writesPerSecond": "Total writes/s",
|
||||||
"host": "Host",
|
"host": "Host",
|
||||||
"port": "Port",
|
"port": "Port",
|
||||||
"dbName": "Database name",
|
"dbName": "Database name",
|
||||||
@@ -1015,11 +1032,9 @@
|
|||||||
"monitorId": "Monitor ID",
|
"monitorId": "Monitor ID",
|
||||||
"runCount": "Run count",
|
"runCount": "Run count",
|
||||||
"failCount": "Count",
|
"failCount": "Count",
|
||||||
"lastRunAt": "Last run at",
|
"nextScheduledAt": "Next run at",
|
||||||
"lockedAt": "Locked at",
|
|
||||||
"lockedBy": "Locked by",
|
"lockedBy": "Locked by",
|
||||||
"lastFinishedAt": "Last finished at",
|
"lastFinishedAt": "Last finished at",
|
||||||
"lastRunTook": "Last run took",
|
|
||||||
"lastFailedAt": "Last failed",
|
"lastFailedAt": "Last failed",
|
||||||
"failReason": "Fail reason"
|
"failReason": "Fail reason"
|
||||||
}
|
}
|
||||||
@@ -1509,6 +1524,11 @@
|
|||||||
"url": {
|
"url": {
|
||||||
"label": "Your status page address",
|
"label": "Your status page address",
|
||||||
"placeholder": "my-status-page"
|
"placeholder": "my-status-page"
|
||||||
|
},
|
||||||
|
"customDomain": {
|
||||||
|
"label": "Custom domain",
|
||||||
|
"placeholder": "status.example.com",
|
||||||
|
"helper": "Optional. Point a DNS record to this Checkmate instance to serve the status page at your own domain."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1607,7 +1627,8 @@
|
|||||||
},
|
},
|
||||||
"table": {
|
"table": {
|
||||||
"headers": {
|
"headers": {
|
||||||
"responseTime": "Response time"
|
"responseTime": "Response time",
|
||||||
|
"uptime": "Uptime %"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"fallback": {
|
"fallback": {
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "ID de monitor",
|
"monitorId": "ID de monitor",
|
||||||
"runCount": "Conteo de ejecuciones",
|
"runCount": "Conteo de ejecuciones",
|
||||||
"failCount": "Conteo de fallas",
|
"failCount": "Conteo de fallas",
|
||||||
"lastRunAt": "Última ejecución",
|
|
||||||
"lockedAt": "Bloqueado a las",
|
|
||||||
"lastFinishedAt": "Última finalización",
|
"lastFinishedAt": "Última finalización",
|
||||||
"lastRunTook": "Última ejecución tomó",
|
|
||||||
"lastFailedAt": "Última falla",
|
"lastFailedAt": "Última falla",
|
||||||
"failReason": "Razón de falla",
|
"failReason": "Razón de falla",
|
||||||
"state": "Estado"
|
"state": "Estado"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "Monitorin tunnus",
|
"monitorId": "Monitorin tunnus",
|
||||||
"runCount": "Suorituskerrat",
|
"runCount": "Suorituskerrat",
|
||||||
"failCount": "Epäonnistumiskerrat",
|
"failCount": "Epäonnistumiskerrat",
|
||||||
"lastRunAt": "Viimeisin suoritus",
|
|
||||||
"lockedAt": "Lukittu",
|
|
||||||
"lastFinishedAt": "Viimeisin valmistuminen",
|
"lastFinishedAt": "Viimeisin valmistuminen",
|
||||||
"lastRunTook": "Viimeisin suoritus kesti",
|
|
||||||
"lastFailedAt": "Viimeisin epäonnistuminen",
|
"lastFailedAt": "Viimeisin epäonnistuminen",
|
||||||
"failReason": "Epäonnistumisen syy",
|
"failReason": "Epäonnistumisen syy",
|
||||||
"state": "Tila"
|
"state": "Tila"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "ID du moniteur",
|
"monitorId": "ID du moniteur",
|
||||||
"runCount": "Nombre d'exécutions",
|
"runCount": "Nombre d'exécutions",
|
||||||
"failCount": "Nombre d'échecs",
|
"failCount": "Nombre d'échecs",
|
||||||
"lastRunAt": "Dernière exécution",
|
|
||||||
"lockedAt": "Verrouillé le",
|
|
||||||
"lastFinishedAt": "Dernière fin",
|
"lastFinishedAt": "Dernière fin",
|
||||||
"lastRunTook": "Durée dernière exécution",
|
|
||||||
"lastFailedAt": "Dernier échec",
|
"lastFailedAt": "Dernier échec",
|
||||||
"failReason": "Raison de l'échec",
|
"failReason": "Raison de l'échec",
|
||||||
"state": "État"
|
"state": "État"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "モニターID",
|
"monitorId": "モニターID",
|
||||||
"runCount": "実行回数",
|
"runCount": "実行回数",
|
||||||
"failCount": "失敗回数",
|
"failCount": "失敗回数",
|
||||||
"lastRunAt": "最終実行日時",
|
|
||||||
"lockedAt": "ロック日時",
|
|
||||||
"lastFinishedAt": "最終完了日時",
|
"lastFinishedAt": "最終完了日時",
|
||||||
"lastRunTook": "最終実行時間",
|
|
||||||
"lastFailedAt": "最終失敗日時",
|
"lastFailedAt": "最終失敗日時",
|
||||||
"failReason": "失敗理由",
|
"failReason": "失敗理由",
|
||||||
"state": "状態"
|
"state": "状態"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "ID do monitor",
|
"monitorId": "ID do monitor",
|
||||||
"runCount": "Contagem de execuções",
|
"runCount": "Contagem de execuções",
|
||||||
"failCount": "Contagem de falhas",
|
"failCount": "Contagem de falhas",
|
||||||
"lastRunAt": "Última execução em",
|
|
||||||
"lockedAt": "Bloqueado em",
|
|
||||||
"lastFinishedAt": "Última conclusão em",
|
"lastFinishedAt": "Última conclusão em",
|
||||||
"lastRunTook": "Última execução durou",
|
|
||||||
"lastFailedAt": "Última falha em",
|
"lastFailedAt": "Última falha em",
|
||||||
"failReason": "Motivo da falha",
|
"failReason": "Motivo da falha",
|
||||||
"state": "Estado"
|
"state": "Estado"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "ID монитора",
|
"monitorId": "ID монитора",
|
||||||
"runCount": "Кол-во запусков",
|
"runCount": "Кол-во запусков",
|
||||||
"failCount": "Кол-во ошибок",
|
"failCount": "Кол-во ошибок",
|
||||||
"lastRunAt": "Последний запуск",
|
|
||||||
"lockedAt": "Заблокировано в",
|
|
||||||
"lastFinishedAt": "Последнее завершение",
|
"lastFinishedAt": "Последнее завершение",
|
||||||
"lastRunTook": "Последний запуск занял",
|
|
||||||
"lastFailedAt": "Последняя ошибка",
|
"lastFailedAt": "Последняя ошибка",
|
||||||
"failReason": "Причина ошибки",
|
"failReason": "Причина ошибки",
|
||||||
"state": "Состояние"
|
"state": "Состояние"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "รหัสมอนิเตอร์",
|
"monitorId": "รหัสมอนิเตอร์",
|
||||||
"runCount": "จำนวนรัน",
|
"runCount": "จำนวนรัน",
|
||||||
"failCount": "จำนวนล้มเหลว",
|
"failCount": "จำนวนล้มเหลว",
|
||||||
"lastRunAt": "รันล่าสุดเมื่อ",
|
|
||||||
"lockedAt": "ล็อกเมื่อ",
|
|
||||||
"lastFinishedAt": "เสร็จสิ้นล่าสุดเมื่อ",
|
"lastFinishedAt": "เสร็จสิ้นล่าสุดเมื่อ",
|
||||||
"lastRunTook": "รันล่าสุดใช้เวลา",
|
|
||||||
"lastFailedAt": "ล้มเหลวล่าสุดเมื่อ",
|
"lastFailedAt": "ล้มเหลวล่าสุดเมื่อ",
|
||||||
"failReason": "สาเหตุที่ล้มเหลว",
|
"failReason": "สาเหตุที่ล้มเหลว",
|
||||||
"state": "สถานะ"
|
"state": "สถานะ"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "Monitör ID",
|
"monitorId": "Monitör ID",
|
||||||
"runCount": "Çalışma sayısı",
|
"runCount": "Çalışma sayısı",
|
||||||
"failCount": "Başarısızlık sayısı",
|
"failCount": "Başarısızlık sayısı",
|
||||||
"lastRunAt": "Son çalışma zamanı",
|
|
||||||
"lockedAt": "Kilitlenme zamanı",
|
|
||||||
"lastFinishedAt": "Son tamamlanma zamanı",
|
"lastFinishedAt": "Son tamamlanma zamanı",
|
||||||
"lastRunTook": "Son çalışma süresi",
|
|
||||||
"lastFailedAt": "Son başarısızlık zamanı",
|
"lastFailedAt": "Son başarısızlık zamanı",
|
||||||
"failReason": "Başarısızlık nedeni",
|
"failReason": "Başarısızlık nedeni",
|
||||||
"state": "Durum"
|
"state": "Durum"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "ID монітора",
|
"monitorId": "ID монітора",
|
||||||
"runCount": "Кількість запусків",
|
"runCount": "Кількість запусків",
|
||||||
"failCount": "Кількість помилок",
|
"failCount": "Кількість помилок",
|
||||||
"lastRunAt": "Останній запуск",
|
|
||||||
"lockedAt": "Заблоковано о",
|
|
||||||
"lastFinishedAt": "Останнє завершення",
|
"lastFinishedAt": "Останнє завершення",
|
||||||
"lastRunTook": "Останній запуск тривав",
|
|
||||||
"lastFailedAt": "Остання помилка",
|
"lastFailedAt": "Остання помилка",
|
||||||
"failReason": "Причина помилки",
|
"failReason": "Причина помилки",
|
||||||
"state": "Стан"
|
"state": "Стан"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "ID trình giám sát",
|
"monitorId": "ID trình giám sát",
|
||||||
"runCount": "Số lần chạy",
|
"runCount": "Số lần chạy",
|
||||||
"failCount": "Số lần lỗi",
|
"failCount": "Số lần lỗi",
|
||||||
"lastRunAt": "Chạy lần cuối lúc",
|
|
||||||
"lockedAt": "Khóa lúc",
|
|
||||||
"lastFinishedAt": "Hoàn thành lần cuối lúc",
|
"lastFinishedAt": "Hoàn thành lần cuối lúc",
|
||||||
"lastRunTook": "Lần chạy cuối mất",
|
|
||||||
"lastFailedAt": "Lỗi lần cuối lúc",
|
"lastFailedAt": "Lỗi lần cuối lúc",
|
||||||
"failReason": "Lý do lỗi",
|
"failReason": "Lý do lỗi",
|
||||||
"state": "Trạng thái"
|
"state": "Trạng thái"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "监控 ID",
|
"monitorId": "监控 ID",
|
||||||
"runCount": "运行次数",
|
"runCount": "运行次数",
|
||||||
"failCount": "失败次数",
|
"failCount": "失败次数",
|
||||||
"lastRunAt": "上次运行于",
|
|
||||||
"lockedAt": "锁定于",
|
|
||||||
"lastFinishedAt": "上次完成于",
|
"lastFinishedAt": "上次完成于",
|
||||||
"lastRunTook": "上次运行耗时",
|
|
||||||
"lastFailedAt": "上次失败于",
|
"lastFailedAt": "上次失败于",
|
||||||
"failReason": "失败原因",
|
"failReason": "失败原因",
|
||||||
"state": "状态"
|
"state": "状态"
|
||||||
|
|||||||
@@ -941,10 +941,7 @@
|
|||||||
"monitorId": "監控 ID",
|
"monitorId": "監控 ID",
|
||||||
"runCount": "執行次數",
|
"runCount": "執行次數",
|
||||||
"failCount": "失敗次數",
|
"failCount": "失敗次數",
|
||||||
"lastRunAt": "最後執行於",
|
|
||||||
"lockedAt": "鎖定於",
|
|
||||||
"lastFinishedAt": "最後完成於",
|
"lastFinishedAt": "最後完成於",
|
||||||
"lastRunTook": "最後執行耗時",
|
|
||||||
"lastFailedAt": "最後失敗於",
|
"lastFailedAt": "最後失敗於",
|
||||||
"failReason": "失敗原因",
|
"failReason": "失敗原因",
|
||||||
"state": "狀態"
|
"state": "狀態"
|
||||||
|
|||||||
@@ -20,9 +20,35 @@ services:
|
|||||||
- server.env
|
- server.env
|
||||||
depends_on:
|
depends_on:
|
||||||
- mongodb
|
- mongodb
|
||||||
|
worker:
|
||||||
|
image: uptime_server:latest
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "52346:52346"
|
||||||
|
env_file:
|
||||||
|
- server.env
|
||||||
|
environment:
|
||||||
|
QUEUE_MODE: "worker"
|
||||||
|
HEALTH_PORT: "52346"
|
||||||
|
stop_grace_period: 30s
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
[
|
||||||
|
"CMD",
|
||||||
|
"node",
|
||||||
|
"-e",
|
||||||
|
"require('http').get('http://localhost:52346/livez',r=>process.exit(r.statusCode===200?0:1)).on('error',()=>process.exit(1))",
|
||||||
|
]
|
||||||
|
interval: 15s
|
||||||
|
timeout: 3s
|
||||||
|
retries: 3
|
||||||
|
depends_on:
|
||||||
|
- mongodb
|
||||||
mongodb:
|
mongodb:
|
||||||
image: uptime_mongo:latest
|
image: uptime_mongo:latest
|
||||||
restart: always
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "27017:27017"
|
||||||
command: ["mongod", "--quiet", "--bind_ip_all"]
|
command: ["mongod", "--quiet", "--bind_ip_all"]
|
||||||
volumes:
|
volumes:
|
||||||
- ./mongo/data:/data/db
|
- ./mongo/data:/data/db
|
||||||
|
|||||||
+2
-1
@@ -11,7 +11,8 @@ LOG_LEVEL=debug
|
|||||||
# Database
|
# Database
|
||||||
# --------
|
# --------
|
||||||
DB_CONNECTION_STRING=mongodb://localhost:27017/uptime_db
|
DB_CONNECTION_STRING=mongodb://localhost:27017/uptime_db
|
||||||
QUEUE_TYPE=superSimpleQueue
|
QUEUE_MODE="primary"
|
||||||
|
QUEUE_PRIMARY_PROCESSES="true"
|
||||||
|
|
||||||
# JWT Authentication
|
# JWT Authentication
|
||||||
# ------------------
|
# ------------------
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export default [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], // Ignore unused variables that start with '_'
|
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }], // Ignore unused variables that start with '_'
|
||||||
"@typescript-eslint/no-explicit-any": "warn", // Warn on 'any' types
|
"@typescript-eslint/no-explicit-any": "warn", // Warn on 'any' types
|
||||||
"mocha/max-top-level-suites": "warn", // Warn if there are too many top-level suites instead of failing
|
"mocha/max-top-level-suites": "warn", // Warn if there are too many top-level suites instead of failing
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ const config: Config = {
|
|||||||
"^.+\\.(t|j)sx?$": ["ts-jest", { useESM: true, tsconfig: "./tsconfig.jest.json" }],
|
"^.+\\.(t|j)sx?$": ["ts-jest", { useESM: true, tsconfig: "./tsconfig.jest.json" }],
|
||||||
},
|
},
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
"^@/validation/(.*)\\.js$": "<rootDir>/src/validation/$1.js",
|
|
||||||
"^@/utils/(.*)\\.js$": "<rootDir>/src/utils/$1.ts",
|
"^@/utils/(.*)\\.js$": "<rootDir>/src/utils/$1.ts",
|
||||||
"^@/(.*)\\.ts$": "<rootDir>/src/$1.ts",
|
"^@/(.*)\\.ts$": "<rootDir>/src/$1.ts",
|
||||||
"^@/(.*)\\.js$": "<rootDir>/src/$1.ts",
|
"^@/(.*)\\.js$": "<rootDir>/src/$1.ts",
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"ignore": ["node_modules/*"],
|
"ignore": ["node_modules/*"],
|
||||||
"watch": ["src/**/*.ts", "src/**/*.js", "*.json"],
|
"watch": ["src/**/*.ts", "src/**/*.js", "*.json", ".env"],
|
||||||
"ext": "ts,js,json"
|
"ext": "ts,js,json"
|
||||||
}
|
}
|
||||||
+168
-2
@@ -3,7 +3,7 @@
|
|||||||
"info": {
|
"info": {
|
||||||
"title": "Checkmate API",
|
"title": "Checkmate API",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Generated from Zod validation schemas. Source of truth: server/src/validation/*.ts"
|
"description": "Generated from Zod validation schemas. Source of truth: server/src/api/validation/*.ts"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
@@ -386,6 +386,10 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["equal", "include", "regex"]
|
"enum": ["equal", "include", "regex"]
|
||||||
},
|
},
|
||||||
|
"method": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["GET", "HEAD"]
|
||||||
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
@@ -398,6 +402,12 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"customUpCodes": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
"secret": {
|
"secret": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -460,6 +470,9 @@
|
|||||||
},
|
},
|
||||||
"updatedAt": {
|
"updatedAt": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"lastEvaluatedAt": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@@ -474,6 +487,7 @@
|
|||||||
"statusWindowThreshold",
|
"statusWindowThreshold",
|
||||||
"ignoreTlsErrors",
|
"ignoreTlsErrors",
|
||||||
"useAdvancedMatching",
|
"useAdvancedMatching",
|
||||||
|
"method",
|
||||||
"notifications",
|
"notifications",
|
||||||
"tags",
|
"tags",
|
||||||
"cpuAlertThreshold",
|
"cpuAlertThreshold",
|
||||||
@@ -487,7 +501,8 @@
|
|||||||
"teamId",
|
"teamId",
|
||||||
"userId",
|
"userId",
|
||||||
"createdAt",
|
"createdAt",
|
||||||
"updatedAt"
|
"updatedAt",
|
||||||
|
"lastEvaluatedAt"
|
||||||
],
|
],
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"nullable": true
|
"nullable": true
|
||||||
@@ -7016,6 +7031,13 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"customUpCodes": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"default": []
|
||||||
|
},
|
||||||
"secret": {
|
"secret": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -7053,6 +7075,10 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"method": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["GET", "HEAD"]
|
||||||
|
},
|
||||||
"gameId": {
|
"gameId": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
@@ -7653,6 +7679,11 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"method": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["GET", "HEAD"],
|
||||||
|
"default": "GET"
|
||||||
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
@@ -7685,6 +7716,13 @@
|
|||||||
},
|
},
|
||||||
"default": []
|
"default": []
|
||||||
},
|
},
|
||||||
|
"customUpCodes": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"default": []
|
||||||
|
},
|
||||||
"secret": {
|
"secret": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -8209,6 +8247,12 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"customUpCodes": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
"secret": {
|
"secret": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -8252,6 +8296,10 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"method": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["GET", "HEAD"]
|
||||||
|
},
|
||||||
"port": {
|
"port": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
@@ -10422,6 +10470,17 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^[a-zA-Z0-9_-]+$"
|
"pattern": "^[a-zA-Z0-9_-]+$"
|
||||||
},
|
},
|
||||||
|
"customDomain": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^(?=.{1,253}$)([a-zA-Z0-9_](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,63}$"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nullable": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"timezone": {
|
"timezone": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -10625,6 +10684,17 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^[a-zA-Z0-9_-]+$"
|
"pattern": "^[a-zA-Z0-9_-]+$"
|
||||||
},
|
},
|
||||||
|
"customDomain": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^(?=.{1,253}$)([a-zA-Z0-9_](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,63}$"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nullable": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"timezone": {
|
"timezone": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -10894,6 +10964,102 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/status-page/resolve": {
|
||||||
|
"get": {
|
||||||
|
"tags": ["status-page"],
|
||||||
|
"summary": "Resolve a published status page by custom domain",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"schema": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["uptime", "infrastructure"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["uptime", "infrastructure"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"name": "type",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"schema": {
|
||||||
|
"type": "number",
|
||||||
|
"nullable": true
|
||||||
|
},
|
||||||
|
"required": false,
|
||||||
|
"name": "timeFrame",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": false,
|
||||||
|
"name": "domain",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"success": {
|
||||||
|
"type": "boolean",
|
||||||
|
"enum": [true]
|
||||||
|
},
|
||||||
|
"msg": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"nullable": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["success", "msg"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "Status page not found"
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal server error",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"success": {
|
||||||
|
"type": "boolean",
|
||||||
|
"enum": [false]
|
||||||
|
},
|
||||||
|
"msg": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"nullable": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["success", "msg"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/status-page/{url}": {
|
"/status-page/{url}": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": ["status-page"],
|
"tags": ["status-page"],
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export function getOpenApiSpec(): JsonObject {
|
|||||||
info: {
|
info: {
|
||||||
title: "Checkmate API",
|
title: "Checkmate API",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
description: "Generated from Zod validation schemas. Source of truth: server/src/validation/*.ts",
|
description: "Generated from Zod validation schemas. Source of truth: server/src/api/validation/*.ts",
|
||||||
},
|
},
|
||||||
servers: [{ url: "/api/v1", description: "Current server" }],
|
servers: [{ url: "/api/v1", description: "Current server" }],
|
||||||
tags: [
|
tags: [
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
recoveryValidation,
|
recoveryValidation,
|
||||||
recoveryTokenBodyValidation,
|
recoveryTokenBodyValidation,
|
||||||
newPasswordValidation,
|
newPasswordValidation,
|
||||||
} from "@/validation/authValidation.js";
|
} from "@/api/validation/authValidation.js";
|
||||||
import {
|
import {
|
||||||
getUserByIdParamValidation,
|
getUserByIdParamValidation,
|
||||||
editUserByIdParamValidation,
|
editUserByIdParamValidation,
|
||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
createUserBodyValidation,
|
createUserBodyValidation,
|
||||||
editUserBodyValidation,
|
editUserBodyValidation,
|
||||||
userResponseSchema,
|
userResponseSchema,
|
||||||
} from "@/validation/userValidation.js";
|
} from "@/api/validation/userValidation.js";
|
||||||
|
|
||||||
const tags = ["auth"];
|
const tags = ["auth"];
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
getTeamChecksQueryValidation,
|
getTeamChecksQueryValidation,
|
||||||
deleteChecksParamValidation,
|
deleteChecksParamValidation,
|
||||||
getChecksSummaryByTeamIdQueryValidation,
|
getChecksSummaryByTeamIdQueryValidation,
|
||||||
} from "@/validation/checkValidation.js";
|
} from "@/api/validation/checkValidation.js";
|
||||||
|
|
||||||
const tags = ["checks"];
|
const tags = ["checks"];
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { registry } from "../registry.js";
|
import { registry } from "../registry.js";
|
||||||
import { bearer, okUnknown, standardErrors } from "../helpers.js";
|
import { bearer, okUnknown, standardErrors } from "../helpers.js";
|
||||||
import { getChecksParamValidation, getChecksQueryValidation } from "@/validation/checkValidation.js";
|
import { getChecksParamValidation, getChecksQueryValidation } from "@/api/validation/checkValidation.js";
|
||||||
|
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { registry } from "../registry.js";
|
import { registry } from "../registry.js";
|
||||||
import { bearer, okJson, okJsonNoData, standardErrors } from "../helpers.js";
|
import { bearer, okJson, okJsonNoData, standardErrors } from "../helpers.js";
|
||||||
import { getIncidentsByTeamQueryValidation, getIncidentSummaryQueryValidation } from "@/validation/incidentValidation.js";
|
import { getIncidentsByTeamQueryValidation, getIncidentSummaryQueryValidation } from "@/api/validation/incidentValidation.js";
|
||||||
|
|
||||||
const tags = ["incidents"];
|
const tags = ["incidents"];
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { registry } from "../registry.js";
|
import { registry } from "../registry.js";
|
||||||
import { bearer, json, okJson, okJsonNoData, standardErrors } from "../helpers.js";
|
import { bearer, json, okJson, okJsonNoData, standardErrors } from "../helpers.js";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { inviteBodyValidation, inviteVerificationBodyValidation } from "@/validation/authValidation.js";
|
import { inviteBodyValidation, inviteVerificationBodyValidation } from "@/api/validation/authValidation.js";
|
||||||
|
|
||||||
const tags = ["invite"];
|
const tags = ["invite"];
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
deleteMaintenanceWindowByIdParamValidation,
|
deleteMaintenanceWindowByIdParamValidation,
|
||||||
editMaintenanceWindowByIdParamValidation,
|
editMaintenanceWindowByIdParamValidation,
|
||||||
editMaintenanceByIdWindowBodyValidation,
|
editMaintenanceByIdWindowBodyValidation,
|
||||||
} from "@/validation/maintenanceWindowValidation.js";
|
} from "@/api/validation/maintenanceWindowValidation.js";
|
||||||
|
|
||||||
const tags = ["maintenance-window"];
|
const tags = ["maintenance-window"];
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import {
|
|||||||
getHardwareDetailsByIdParamValidation,
|
getHardwareDetailsByIdParamValidation,
|
||||||
getHardwareDetailsByIdQueryValidation,
|
getHardwareDetailsByIdQueryValidation,
|
||||||
monitorResponseSchema,
|
monitorResponseSchema,
|
||||||
} from "@/validation/monitorValidation.js";
|
} from "@/api/validation/monitorValidation.js";
|
||||||
import { updateNotificationsValidation } from "@/validation/notificationValidation.js";
|
import { updateNotificationsValidation } from "@/api/validation/notificationValidation.js";
|
||||||
|
|
||||||
const tags = ["monitors"];
|
const tags = ["monitors"];
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
getNotificationByIdParamValidation,
|
getNotificationByIdParamValidation,
|
||||||
editNotificationParamValidation,
|
editNotificationParamValidation,
|
||||||
testAllNotificationsBodyValidation,
|
testAllNotificationsBodyValidation,
|
||||||
} from "@/validation/notificationValidation.js";
|
} from "@/api/validation/notificationValidation.js";
|
||||||
|
|
||||||
const tags = ["notifications"];
|
const tags = ["notifications"];
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { registry } from "../registry.js";
|
import { registry } from "../registry.js";
|
||||||
import { bearer, json, okJsonNoData, okUnknown, standardErrors } from "../helpers.js";
|
import { bearer, json, okJsonNoData, okUnknown, standardErrors } from "../helpers.js";
|
||||||
import { updateAppSettingsBodyValidation } from "@/validation/settingsValidation.js";
|
import { updateAppSettingsBodyValidation } from "@/api/validation/settingsValidation.js";
|
||||||
import { sendTestEmailBodyValidation } from "@/validation/notificationValidation.js";
|
import { sendTestEmailBodyValidation } from "@/api/validation/notificationValidation.js";
|
||||||
|
|
||||||
const tags = ["settings"];
|
const tags = ["settings"];
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import { registry } from "../registry.js";
|
import { registry } from "../registry.js";
|
||||||
import { bearer, multipart, okJsonNoData, okUnknown, standardErrors } from "../helpers.js";
|
import { bearer, multipart, okJsonNoData, okUnknown, standardErrors } from "../helpers.js";
|
||||||
import { createStatusPageBodyValidation, getStatusPageParamValidation, getStatusPageQueryValidation } from "@/validation/statusPageValidation.js";
|
import {
|
||||||
|
createStatusPageBodyValidation,
|
||||||
|
getStatusPageParamValidation,
|
||||||
|
getStatusPageQueryValidation,
|
||||||
|
resolveStatusPageQueryValidation,
|
||||||
|
} from "@/api/validation/statusPageValidation.js";
|
||||||
|
|
||||||
const tags = ["status-page"];
|
const tags = ["status-page"];
|
||||||
|
|
||||||
@@ -33,6 +38,15 @@ registry.registerPath({
|
|||||||
responses: { "200": okUnknown, ...standardErrors },
|
responses: { "200": okUnknown, ...standardErrors },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
registry.registerPath({
|
||||||
|
method: "get",
|
||||||
|
path: "/status-page/resolve",
|
||||||
|
tags,
|
||||||
|
summary: "Resolve a published status page by custom domain",
|
||||||
|
request: { query: resolveStatusPageQueryValidation },
|
||||||
|
responses: { "200": okUnknown, "404": { description: "Status page not found" }, "500": standardErrors["500"] },
|
||||||
|
});
|
||||||
|
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: "get",
|
method: "get",
|
||||||
path: "/status-page/{url}",
|
path: "/status-page/{url}",
|
||||||
|
|||||||
Generated
+1215
-988
File diff suppressed because it is too large.
Load diff
+2
-5
@@ -22,7 +22,7 @@
|
|||||||
"format-check": "prettier --check ."
|
"format-check": "prettier --check ."
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"**/*": "prettier --write"
|
"**/*": "prettier --write --ignore-unknown"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
@@ -33,7 +33,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.14.3",
|
"@grpc/grpc-js": "^1.14.3",
|
||||||
"@grpc/proto-loader": "^0.8.0",
|
"@grpc/proto-loader": "^0.8.0",
|
||||||
"@pulsecron/pulse": "1.6.8",
|
|
||||||
"axios": "^1.15.2",
|
"axios": "^1.15.2",
|
||||||
"bcryptjs": "3.0.2",
|
"bcryptjs": "3.0.2",
|
||||||
"cacheable-lookup": "7.0.0",
|
"cacheable-lookup": "7.0.0",
|
||||||
@@ -48,12 +47,10 @@
|
|||||||
"got": "14.4.7",
|
"got": "14.4.7",
|
||||||
"handlebars": "^4.7.8",
|
"handlebars": "^4.7.8",
|
||||||
"helmet": "^8.0.0",
|
"helmet": "^8.0.0",
|
||||||
"ioredis": "^5.4.2",
|
|
||||||
"isomorphic-dompurify": "^2.26.0",
|
"isomorphic-dompurify": "^2.26.0",
|
||||||
"jmespath": "^0.16.0",
|
"jmespath": "^0.16.0",
|
||||||
"jsdom": "^26.1.0",
|
"jsdom": "^26.1.0",
|
||||||
"jsonwebtoken": "9.0.2",
|
"jsonwebtoken": "9.0.2",
|
||||||
"less-simple-scheduler": "2.6.0",
|
|
||||||
"mailersend": "^2.2.0",
|
"mailersend": "^2.2.0",
|
||||||
"mjml": "^5.0.0-alpha.4",
|
"mjml": "^5.0.0-alpha.4",
|
||||||
"mongoose": "^8.3.3",
|
"mongoose": "^8.3.3",
|
||||||
@@ -62,7 +59,6 @@
|
|||||||
"ping": "0.4.4",
|
"ping": "0.4.4",
|
||||||
"sharp": "0.33.5",
|
"sharp": "0.33.5",
|
||||||
"ssl-checker": "2.0.10",
|
"ssl-checker": "2.0.10",
|
||||||
"super-simple-scheduler": "1.9.2",
|
|
||||||
"swagger-ui-express": "5.0.1",
|
"swagger-ui-express": "5.0.1",
|
||||||
"winston": "^3.13.0",
|
"winston": "^3.13.0",
|
||||||
"ws": "^8.19.0",
|
"ws": "^8.19.0",
|
||||||
@@ -96,6 +92,7 @@
|
|||||||
"globals": "^15.14.0",
|
"globals": "^15.14.0",
|
||||||
"jest": "^30.2.0",
|
"jest": "^30.2.0",
|
||||||
"lint-staged": "^16.2.7",
|
"lint-staged": "^16.2.7",
|
||||||
|
"mongodb-memory-server": "11.2.0",
|
||||||
"nodemon": "^3.1.11",
|
"nodemon": "^3.1.11",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"prettier-plugin-ini": "1.3.0",
|
"prettier-plugin-ini": "1.3.0",
|
||||||
|
|||||||
@@ -0,0 +1,269 @@
|
|||||||
|
import mongoose from "mongoose";
|
||||||
|
import { MonitorModel } from "../dist/domain/monitors/monitor.model.js";
|
||||||
|
import { UserModel } from "../dist/domain/users/user.model.js";
|
||||||
|
|
||||||
|
// Seeds a large number of HTTP monitors against real, resolving domains so the
|
||||||
|
// scheduler can be exercised under load. Run after `npm run build` (imports the
|
||||||
|
// compiled models from dist/, like scripts/generate-checks.js).
|
||||||
|
//
|
||||||
|
// node scripts/seed-monitors.js # 10k monitors, owner auto-detected
|
||||||
|
// COUNT=2000 INTERVAL=30000 node scripts/seed-monitors.js
|
||||||
|
// CLEAR=true node scripts/seed-monitors.js # remove prior seed monitors first
|
||||||
|
// TEAM_ID=<id> USER_ID=<id> node scripts/seed-monitors.js
|
||||||
|
//
|
||||||
|
// NOTE: the running queue only schedules monitors it finds at init(), so restart
|
||||||
|
// the server after seeding for the new monitors to actually start checking.
|
||||||
|
|
||||||
|
const DEFAULT_COUNT = 500;
|
||||||
|
const DEFAULT_BATCH = 1_000;
|
||||||
|
const DEFAULT_INTERVAL = 60_000;
|
||||||
|
const NAME_PREFIX = "Seed";
|
||||||
|
// Stored in `description` so a re-run with CLEAR=true can find and remove them.
|
||||||
|
const SEED_MARKER = "checkmate-scaling-seed";
|
||||||
|
|
||||||
|
// A spread of well-known, reliably-resolving domains across regions, TLDs and
|
||||||
|
// CDNs. Monitors round-robin through this pool, so the load is split across many
|
||||||
|
// hosts rather than hammering one. Every entry returns a real HTTP response
|
||||||
|
// (some may 403/429 under load — still a valid response for scaling purposes).
|
||||||
|
const DOMAINS = [
|
||||||
|
"google.com",
|
||||||
|
"youtube.com",
|
||||||
|
"facebook.com",
|
||||||
|
"wikipedia.org",
|
||||||
|
"amazon.com",
|
||||||
|
"reddit.com",
|
||||||
|
"x.com",
|
||||||
|
"instagram.com",
|
||||||
|
"linkedin.com",
|
||||||
|
"microsoft.com",
|
||||||
|
"apple.com",
|
||||||
|
"cloudflare.com",
|
||||||
|
"github.com",
|
||||||
|
"gitlab.com",
|
||||||
|
"stackoverflow.com",
|
||||||
|
"netflix.com",
|
||||||
|
"bing.com",
|
||||||
|
"yahoo.com",
|
||||||
|
"duckduckgo.com",
|
||||||
|
"mozilla.org",
|
||||||
|
"wordpress.org",
|
||||||
|
"wordpress.com",
|
||||||
|
"adobe.com",
|
||||||
|
"salesforce.com",
|
||||||
|
"oracle.com",
|
||||||
|
"ibm.com",
|
||||||
|
"intel.com",
|
||||||
|
"nvidia.com",
|
||||||
|
"amd.com",
|
||||||
|
"dell.com",
|
||||||
|
"hp.com",
|
||||||
|
"cisco.com",
|
||||||
|
"vmware.com",
|
||||||
|
"redhat.com",
|
||||||
|
"ubuntu.com",
|
||||||
|
"debian.org",
|
||||||
|
"kernel.org",
|
||||||
|
"python.org",
|
||||||
|
"nodejs.org",
|
||||||
|
"npmjs.com",
|
||||||
|
"docker.com",
|
||||||
|
"kubernetes.io",
|
||||||
|
"golang.org",
|
||||||
|
"rust-lang.org",
|
||||||
|
"php.net",
|
||||||
|
"ruby-lang.org",
|
||||||
|
"java.com",
|
||||||
|
"spring.io",
|
||||||
|
"djangoproject.com",
|
||||||
|
"flask.palletsprojects.com",
|
||||||
|
"vuejs.org",
|
||||||
|
"reactjs.org",
|
||||||
|
"angular.io",
|
||||||
|
"svelte.dev",
|
||||||
|
"jquery.com",
|
||||||
|
"npm.im",
|
||||||
|
"pypi.org",
|
||||||
|
"rubygems.org",
|
||||||
|
"packagist.org",
|
||||||
|
"maven.apache.org",
|
||||||
|
"apache.org",
|
||||||
|
"nginx.org",
|
||||||
|
"postgresql.org",
|
||||||
|
"mysql.com",
|
||||||
|
"mongodb.com",
|
||||||
|
"redis.io",
|
||||||
|
"elastic.co",
|
||||||
|
"grafana.com",
|
||||||
|
"prometheus.io",
|
||||||
|
"hashicorp.com",
|
||||||
|
"digitalocean.com",
|
||||||
|
"linode.com",
|
||||||
|
"vultr.com",
|
||||||
|
"heroku.com",
|
||||||
|
"netlify.com",
|
||||||
|
"vercel.com",
|
||||||
|
"render.com",
|
||||||
|
"fly.io",
|
||||||
|
"railway.app",
|
||||||
|
"cloudinary.com",
|
||||||
|
"twilio.com",
|
||||||
|
"stripe.com",
|
||||||
|
"paypal.com",
|
||||||
|
"shopify.com",
|
||||||
|
"squarespace.com",
|
||||||
|
"wix.com",
|
||||||
|
"godaddy.com",
|
||||||
|
"namecheap.com",
|
||||||
|
"name.com",
|
||||||
|
"gandi.net",
|
||||||
|
"bbc.co.uk",
|
||||||
|
"theguardian.com",
|
||||||
|
"nytimes.com",
|
||||||
|
"washingtonpost.com",
|
||||||
|
"cnn.com",
|
||||||
|
"reuters.com",
|
||||||
|
"bloomberg.com",
|
||||||
|
"forbes.com",
|
||||||
|
"wsj.com",
|
||||||
|
"economist.com",
|
||||||
|
"nature.com",
|
||||||
|
"sciencedirect.com",
|
||||||
|
"arxiv.org",
|
||||||
|
"mit.edu",
|
||||||
|
"stanford.edu",
|
||||||
|
"harvard.edu",
|
||||||
|
"berkeley.edu",
|
||||||
|
"ox.ac.uk",
|
||||||
|
"cam.ac.uk",
|
||||||
|
"ethz.ch",
|
||||||
|
"spotify.com",
|
||||||
|
"soundcloud.com",
|
||||||
|
"twitch.tv",
|
||||||
|
"vimeo.com",
|
||||||
|
"dailymotion.com",
|
||||||
|
"imdb.com",
|
||||||
|
"wikimedia.org",
|
||||||
|
"archive.org",
|
||||||
|
"ietf.org",
|
||||||
|
"w3.org",
|
||||||
|
"who.int",
|
||||||
|
"un.org",
|
||||||
|
"europa.eu",
|
||||||
|
"gov.uk",
|
||||||
|
"canada.ca",
|
||||||
|
"alibaba.com",
|
||||||
|
"aliexpress.com",
|
||||||
|
"baidu.com",
|
||||||
|
"tencent.com",
|
||||||
|
"naver.com",
|
||||||
|
"rakuten.co.jp",
|
||||||
|
"yandex.com",
|
||||||
|
"ozon.ru",
|
||||||
|
"mercadolibre.com",
|
||||||
|
"flipkart.com",
|
||||||
|
"booking.com",
|
||||||
|
"airbnb.com",
|
||||||
|
"expedia.com",
|
||||||
|
"tripadvisor.com",
|
||||||
|
"uber.com",
|
||||||
|
"dropbox.com",
|
||||||
|
"box.com",
|
||||||
|
"atlassian.com",
|
||||||
|
"trello.com",
|
||||||
|
"notion.so",
|
||||||
|
"slack.com",
|
||||||
|
"zoom.us",
|
||||||
|
"asana.com",
|
||||||
|
"figma.com",
|
||||||
|
"canva.com",
|
||||||
|
];
|
||||||
|
|
||||||
|
const parseObjectId = (value) => {
|
||||||
|
if (!value) return null;
|
||||||
|
try {
|
||||||
|
return new mongoose.Types.ObjectId(value);
|
||||||
|
} catch {
|
||||||
|
console.warn(`Ignoring invalid ObjectId '${value}'`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Monitors need a real teamId/userId to show up for an account and to be picked
|
||||||
|
// up by the queue. Prefer explicit env ids, otherwise derive from the oldest
|
||||||
|
// existing user (the typical single-tenant dev setup).
|
||||||
|
async function resolveOwner() {
|
||||||
|
const teamId = parseObjectId(process.env.TEAM_ID);
|
||||||
|
const userId = parseObjectId(process.env.USER_ID);
|
||||||
|
if (teamId && userId) return { teamId, userId };
|
||||||
|
|
||||||
|
const user = await UserModel.findOne(userId ? { _id: userId } : {}).sort({ createdAt: 1 });
|
||||||
|
if (!user?.teamId) {
|
||||||
|
throw new Error(
|
||||||
|
"Could not determine an owner: no existing user with a teamId. " + "Create an account first, or pass TEAM_ID and USER_ID explicitly."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return { teamId: teamId ?? user.teamId, userId: user._id };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
const mongoUri = process.env.MONGO_URI ?? "mongodb://localhost:27017/uptime_db";
|
||||||
|
const total = Number(process.env.COUNT ?? DEFAULT_COUNT);
|
||||||
|
const batchSize = Number(process.env.BATCH_SIZE ?? DEFAULT_BATCH);
|
||||||
|
const interval = Number(process.env.INTERVAL ?? DEFAULT_INTERVAL);
|
||||||
|
|
||||||
|
console.log(`Connecting to MongoDB at ${mongoUri}`);
|
||||||
|
await mongoose.connect(mongoUri);
|
||||||
|
|
||||||
|
const { teamId, userId } = await resolveOwner();
|
||||||
|
|
||||||
|
if (process.env.CLEAR === "true") {
|
||||||
|
const { deletedCount } = await MonitorModel.deleteMany({ description: SEED_MARKER });
|
||||||
|
console.log(`Removed ${deletedCount} previously seeded monitors`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`Seeding ${total} http monitors for team ${teamId} (user ${userId}) across ${DOMAINS.length} domains, ` +
|
||||||
|
`interval ${interval}ms, in batches of ${batchSize}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const docs = [];
|
||||||
|
const startTime = Date.now();
|
||||||
|
let inserted = 0;
|
||||||
|
|
||||||
|
for (let i = 0; i < total; i += 1) {
|
||||||
|
const domain = DOMAINS[i % DOMAINS.length];
|
||||||
|
docs.push({
|
||||||
|
userId,
|
||||||
|
teamId,
|
||||||
|
name: `${NAME_PREFIX} ${String(i + 1).padStart(5, "0")} ${domain}`,
|
||||||
|
description: SEED_MARKER,
|
||||||
|
type: "http",
|
||||||
|
url: `https://${domain}`,
|
||||||
|
isActive: true,
|
||||||
|
interval,
|
||||||
|
lastEvaluatedAt: 0, // evaluator watermark; without it findUnevaluatedByMonitorId gets new Date(undefined)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (docs.length === batchSize) {
|
||||||
|
await MonitorModel.insertMany(docs, { ordered: false });
|
||||||
|
inserted += docs.length;
|
||||||
|
console.log(`Inserted ${inserted} / ${total}`);
|
||||||
|
docs.length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (docs.length > 0) {
|
||||||
|
await MonitorModel.insertMany(docs, { ordered: false });
|
||||||
|
inserted += docs.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
await mongoose.disconnect();
|
||||||
|
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
|
||||||
|
console.log(`Finished inserting ${inserted} monitors in ${duration}s`);
|
||||||
|
console.log("Restart the server so the queue schedules the new monitors.");
|
||||||
|
}
|
||||||
|
|
||||||
|
run().catch((error) => {
|
||||||
|
console.error("Failed to seed monitors", error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
import { requireTeamId, requireUserEmail, requireUserId, requireUserRoles } from "@/controllers/controllerUtils.js";
|
import { requireTeamId, requireUserEmail, requireUserId, requireUserRoles } from "@/api/controllers/controllerUtils.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
registrationBodyValidation,
|
registrationBodyValidation,
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
recoveryValidation,
|
recoveryValidation,
|
||||||
recoveryTokenBodyValidation,
|
recoveryTokenBodyValidation,
|
||||||
newPasswordValidation,
|
newPasswordValidation,
|
||||||
} from "@/validation/authValidation.js";
|
} from "@/api/validation/authValidation.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
editUserBodyValidation,
|
editUserBodyValidation,
|
||||||
@@ -18,8 +18,8 @@ import {
|
|||||||
editUserByIdBodyValidation,
|
editUserByIdBodyValidation,
|
||||||
editSuperadminUserByIdBodyValidation,
|
editSuperadminUserByIdBodyValidation,
|
||||||
editUserPasswordByIdBodyValidation,
|
editUserPasswordByIdBodyValidation,
|
||||||
} from "@/validation/userValidation.js";
|
} from "@/api/validation/userValidation.js";
|
||||||
import { IUserService } from "@/service/index.js";
|
import { IUserService } from "@/domain/users/user.service.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "authController";
|
const SERVICE_NAME = "authController";
|
||||||
|
|
||||||
+3
-3
@@ -6,9 +6,9 @@ import {
|
|||||||
getTeamChecksQueryValidation,
|
getTeamChecksQueryValidation,
|
||||||
getChecksSummaryByTeamIdQueryValidation,
|
getChecksSummaryByTeamIdQueryValidation,
|
||||||
deleteChecksParamValidation,
|
deleteChecksParamValidation,
|
||||||
} from "@/validation/checkValidation.js";
|
} from "@/api/validation/checkValidation.js";
|
||||||
import { ICheckService } from "@/service/index.js";
|
import { ICheckService } from "@/domain/checks/check.service.js";
|
||||||
import { requireTeamId } from "@/controllers/controllerUtils.js";
|
import { requireTeamId } from "@/api/controllers/controllerUtils.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "checkController";
|
const SERVICE_NAME = "checkController";
|
||||||
|
|
||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
import { Monitor, type MonitorType, MonitorTypes, UserRole } from "@/types/index.js";
|
import { Monitor, MonitorTypes, type MonitorType } from "@/domain/monitors/monitor.types.js";
|
||||||
|
import { UserRole } from "@/domain/users/user.type.js";
|
||||||
import sslChecker, { SSLDetails } from "ssl-checker";
|
import sslChecker, { SSLDetails } from "ssl-checker";
|
||||||
type SSLCheckerType = typeof sslChecker;
|
type SSLCheckerType = typeof sslChecker;
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { IDiagnosticService } from "@/service/index.js";
|
import { IDiagnosticService } from "@/domain/diagnostics/diagnostic.service.js";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
|
||||||
const SERVICE_NAME = "diagnosticController";
|
const SERVICE_NAME = "diagnosticController";
|
||||||
+2
-3
@@ -1,8 +1,7 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { getChecksParamValidation, getChecksQueryValidation } from "@/validation/checkValidation.js";
|
import { getChecksParamValidation, getChecksQueryValidation } from "@/api/validation/checkValidation.js";
|
||||||
import type { IGeoChecksService } from "@/service/business/geoChecksService.js";
|
import type { IGeoChecksService } from "@/domain/geo-checks/geo-check.service.js";
|
||||||
import { requireTeamId } from "./controllerUtils.js";
|
import { requireTeamId } from "./controllerUtils.js";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
|
||||||
|
|
||||||
const SERVICE_NAME = "geoCheckController";
|
const SERVICE_NAME = "geoCheckController";
|
||||||
|
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { requireTeamId, requireUserId, requireUserEmail, extractString } from "./controllerUtils.js";
|
import { requireTeamId, requireUserId, requireUserEmail, extractString } from "./controllerUtils.js";
|
||||||
import { IIncidentService } from "@/service/index.js";
|
import { IIncidentService } from "@/domain/incidents/incident.service.js";
|
||||||
import { getIncidentsByTeamQueryValidation, getIncidentSummaryQueryValidation } from "@/validation/incidentValidation.js";
|
import { getIncidentsByTeamQueryValidation, getIncidentSummaryQueryValidation } from "@/api/validation/incidentValidation.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "IncidentController";
|
const SERVICE_NAME = "IncidentController";
|
||||||
|
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { inviteBodyValidation, inviteVerificationBodyValidation } from "@/validation/authValidation.js";
|
import { inviteBodyValidation, inviteVerificationBodyValidation } from "@/api/validation/authValidation.js";
|
||||||
import { requireFirstName, requireTeamId, requireUserRoles } from "@/controllers/controllerUtils.js";
|
import { requireFirstName, requireTeamId, requireUserRoles } from "@/api/controllers/controllerUtils.js";
|
||||||
import { IInviteService } from "@/service/index.js";
|
import { IInviteService } from "@/domain/invites/invite.service.js";
|
||||||
const SERVICE_NAME = "inviteController";
|
const SERVICE_NAME = "inviteController";
|
||||||
|
|
||||||
export interface IInviteController {
|
export interface IInviteController {
|
||||||
File renamed without changes.
+3
-3
@@ -7,9 +7,9 @@ import {
|
|||||||
getMaintenanceWindowsByMonitorIdParamValidation,
|
getMaintenanceWindowsByMonitorIdParamValidation,
|
||||||
getMaintenanceWindowsByTeamIdQueryValidation,
|
getMaintenanceWindowsByTeamIdQueryValidation,
|
||||||
deleteMaintenanceWindowByIdParamValidation,
|
deleteMaintenanceWindowByIdParamValidation,
|
||||||
} from "@/validation/maintenanceWindowValidation.js";
|
} from "@/api/validation/maintenanceWindowValidation.js";
|
||||||
import { requireTeamId } from "@/controllers/controllerUtils.js";
|
import { requireTeamId } from "@/api/controllers/controllerUtils.js";
|
||||||
import { IMaintenanceWindowService } from "@/service/index.js";
|
import { IMaintenanceWindowService } from "@/domain/maintenance-windows/maintenance-window.service.js";
|
||||||
|
|
||||||
export interface IMaintenanceWindowController {
|
export interface IMaintenanceWindowController {
|
||||||
createMaintenanceWindows: (req: Request, res: Response, next: NextFunction) => Promise<Response | void>;
|
createMaintenanceWindows: (req: Request, res: Response, next: NextFunction) => Promise<Response | void>;
|
||||||
+5
-4
@@ -1,5 +1,5 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { updateNotificationsValidation } from "@/validation/notificationValidation.js";
|
import { updateNotificationsValidation } from "@/api/validation/notificationValidation.js";
|
||||||
import {
|
import {
|
||||||
getMonitorByIdParamValidation,
|
getMonitorByIdParamValidation,
|
||||||
getMonitorByIdQueryValidation,
|
getMonitorByIdQueryValidation,
|
||||||
@@ -15,11 +15,12 @@ import {
|
|||||||
getUptimeDetailsByIdQueryValidation,
|
getUptimeDetailsByIdQueryValidation,
|
||||||
importMonitorsBodyValidation,
|
importMonitorsBodyValidation,
|
||||||
bulkPauseMonitorBodyValidation,
|
bulkPauseMonitorBodyValidation,
|
||||||
} from "@/validation/monitorValidation.js";
|
} from "@/api/validation/monitorValidation.js";
|
||||||
import sslChecker from "ssl-checker";
|
import sslChecker from "ssl-checker";
|
||||||
import { fetchMonitorCertificate, requireTeamId, requireUserId } from "@/controllers/controllerUtils.js";
|
import { fetchMonitorCertificate, requireTeamId, requireUserId } from "@/api/controllers/controllerUtils.js";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
import { IMonitorService, INotificationsService } from "@/service/index.js";
|
import { IMonitorService } from "@/domain/monitors/monitor.service.js";
|
||||||
|
import { INotificationsService } from "@/domain/notifications/notification.service.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "monitorController";
|
const SERVICE_NAME = "monitorController";
|
||||||
|
|
||||||
+3
-3
@@ -7,11 +7,11 @@ import {
|
|||||||
testNotificationBodyValidation,
|
testNotificationBodyValidation,
|
||||||
editNotificationParamValidation,
|
editNotificationParamValidation,
|
||||||
testAllNotificationsBodyValidation,
|
testAllNotificationsBodyValidation,
|
||||||
} from "@/validation/notificationValidation.js";
|
} from "@/api/validation/notificationValidation.js";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
import { INotificationsService } from "@/service/index.js";
|
import { INotificationsService } from "@/domain/notifications/notification.service.js";
|
||||||
import { requireTeamId, requireUserId } from "./controllerUtils.js";
|
import { requireTeamId, requireUserId } from "./controllerUtils.js";
|
||||||
import { IMonitorsRepository } from "@/repositories/index.js";
|
import { IMonitorsRepository } from "@/domain/monitors/monitor.repository.interface.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "NotificationController";
|
const SERVICE_NAME = "NotificationController";
|
||||||
|
|
||||||
+8
-11
@@ -1,5 +1,5 @@
|
|||||||
import { IJobQueue } from "@/service/index.js";
|
import { IJobScheduler } from "@/worker/worker.interface.js";
|
||||||
import { getQueueJobsQueryValidation } from "@/validation/queueValidation.js";
|
import { getQueueJobsQueryValidation } from "@/api/validation/queueValidation.js";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
|
||||||
const SERVICE_NAME = "JobQueueController";
|
const SERVICE_NAME = "JobQueueController";
|
||||||
@@ -13,10 +13,7 @@ export interface IJobQueueController {
|
|||||||
|
|
||||||
class JobQueueController implements IJobQueueController {
|
class JobQueueController implements IJobQueueController {
|
||||||
static SERVICE_NAME = SERVICE_NAME;
|
static SERVICE_NAME = SERVICE_NAME;
|
||||||
private jobQueue: IJobQueue;
|
constructor(private scheduler: IJobScheduler) {}
|
||||||
constructor(jobQueue: IJobQueue) {
|
|
||||||
this.jobQueue = jobQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
get serviceName() {
|
get serviceName() {
|
||||||
return JobQueueController.SERVICE_NAME;
|
return JobQueueController.SERVICE_NAME;
|
||||||
@@ -24,7 +21,7 @@ class JobQueueController implements IJobQueueController {
|
|||||||
|
|
||||||
getMetrics = async (req: Request, res: Response, next: NextFunction) => {
|
getMetrics = async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const metrics = await this.jobQueue.getMetrics();
|
const metrics = await this.scheduler.getMetrics();
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: "Queue metrics fetched successfully",
|
msg: "Queue metrics fetched successfully",
|
||||||
@@ -38,7 +35,7 @@ class JobQueueController implements IJobQueueController {
|
|||||||
getJobs = async (req: Request, res: Response, next: NextFunction) => {
|
getJobs = async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const pagination = getQueueJobsQueryValidation.parse(req.query);
|
const pagination = getQueueJobsQueryValidation.parse(req.query);
|
||||||
const { jobs, count } = await this.jobQueue.getJobs(pagination);
|
const { jobs, count } = await this.scheduler.getJobs(pagination);
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: "Queue jobs fetched successfully",
|
msg: "Queue jobs fetched successfully",
|
||||||
@@ -52,8 +49,8 @@ class JobQueueController implements IJobQueueController {
|
|||||||
getAllMetrics = async (req: Request, res: Response, next: NextFunction) => {
|
getAllMetrics = async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const pagination = getQueueJobsQueryValidation.parse(req.query);
|
const pagination = getQueueJobsQueryValidation.parse(req.query);
|
||||||
const { jobs, count } = await this.jobQueue.getJobs(pagination);
|
const { jobs, count } = await this.scheduler.getJobs(pagination);
|
||||||
const metrics = await this.jobQueue.getMetrics();
|
const metrics = await this.scheduler.getMetrics();
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: "Queue metrics fetched successfully",
|
msg: "Queue metrics fetched successfully",
|
||||||
@@ -66,7 +63,7 @@ class JobQueueController implements IJobQueueController {
|
|||||||
|
|
||||||
flushQueue = async (req: Request, res: Response, next: NextFunction) => {
|
flushQueue = async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const result = await this.jobQueue.flushQueues();
|
const result = await this.scheduler.flushQueues();
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: "Queue flushed successfully",
|
msg: "Queue flushed successfully",
|
||||||
+5
-4
@@ -1,9 +1,10 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { updateAppSettingsBodyValidation } from "@/validation/settingsValidation.js";
|
import { updateAppSettingsBodyValidation } from "@/api/validation/settingsValidation.js";
|
||||||
import { sendTestEmailBodyValidation } from "@/validation/notificationValidation.js";
|
import { sendTestEmailBodyValidation } from "@/api/validation/notificationValidation.js";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
import { IEmailService, ISettingsService } from "@/service/index.js";
|
import { ISettingsService } from "@/domain/app-settings/app-settings.service.js";
|
||||||
import { Settings } from "@/types/settings.js";
|
import { IEmailService } from "@/service/emailService.js";
|
||||||
|
import { Settings } from "@/domain/app-settings/app-settings.type.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "SettingsController";
|
const SERVICE_NAME = "SettingsController";
|
||||||
|
|
||||||
+73
-37
@@ -5,13 +5,16 @@ import {
|
|||||||
getStatusPageParamValidation,
|
getStatusPageParamValidation,
|
||||||
getStatusPageQueryValidation,
|
getStatusPageQueryValidation,
|
||||||
imageValidation,
|
imageValidation,
|
||||||
} from "@/validation/statusPageValidation.js";
|
resolveStatusPageQueryValidation,
|
||||||
|
} from "@/api/validation/statusPageValidation.js";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
import { requireTeamId, requireUserId } from "@/controllers/controllerUtils.js";
|
import { requireTeamId, requireUserId } from "@/api/controllers/controllerUtils.js";
|
||||||
import { IStatusPageService } from "@/service/business/statusPageService.js";
|
import { IStatusPageService } from "@/domain/status-pages/status-page.service.js";
|
||||||
import { IMonitorsRepository } from "@/repositories/index.js";
|
import { IMonitorsRepository } from "@/domain/monitors/monitor.repository.interface.js";
|
||||||
import { ISettingsService } from "@/service/system/settingsService.js";
|
import { ISettingsService } from "@/domain/app-settings/app-settings.service.js";
|
||||||
import { NormalizeData } from "@/utils/dataUtils.js";
|
import { NormalizeData } from "@/utils/dataUtils.js";
|
||||||
|
import { resolveStatusPageDomainFromRequest } from "@/utils/statusPageDomain.js";
|
||||||
|
import type { StatusPage } from "@/domain/status-pages/status-page.type.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "statusPageController";
|
const SERVICE_NAME = "statusPageController";
|
||||||
|
|
||||||
@@ -20,6 +23,7 @@ export interface IStatusPageController {
|
|||||||
createStatusPage(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
createStatusPage(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
||||||
updateStatusPage(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
updateStatusPage(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
||||||
getStatusPageByUrl(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
getStatusPageByUrl(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
||||||
|
resolveStatusPageByDomain(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
||||||
getStatusPagesByTeamId(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
getStatusPagesByTeamId(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
||||||
deleteStatusPage(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
deleteStatusPage(req: Request, res: Response, next: NextFunction): Promise<Response | void>;
|
||||||
}
|
}
|
||||||
@@ -39,6 +43,41 @@ class StatusPageController implements IStatusPageController {
|
|||||||
return StatusPageController.SERVICE_NAME;
|
return StatusPageController.SERVICE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private buildStatusPagePayload = async (statusPage: StatusPage, req: Request) => {
|
||||||
|
if (!statusPage.isPublished) {
|
||||||
|
const teamId = requireTeamId(req?.user?.teamId);
|
||||||
|
if (statusPage.teamId !== teamId) {
|
||||||
|
throw new AppError({ message: "Forbidden", status: 403 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const settings = await this.settingsService.getDBSettings();
|
||||||
|
const showURL = settings.showURL;
|
||||||
|
|
||||||
|
const monitors = await this.monitorsRepository.findByIds(statusPage.monitors);
|
||||||
|
const monitorOrder = new Map(statusPage.monitors.map((id, index) => [id, index]));
|
||||||
|
const sortedMonitors = [...monitors].sort((a, b) => {
|
||||||
|
const orderA = monitorOrder.get(a.id) ?? Number.MAX_SAFE_INTEGER;
|
||||||
|
const orderB = monitorOrder.get(b.id) ?? Number.MAX_SAFE_INTEGER;
|
||||||
|
return orderA - orderB;
|
||||||
|
});
|
||||||
|
|
||||||
|
const normalizedMonitors = sortedMonitors.map((monitor) => {
|
||||||
|
const normalizedChecks = NormalizeData(monitor.recentChecks, 10, 100);
|
||||||
|
if (!showURL) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
const { url, port, secret, notifications, ...rest } = monitor;
|
||||||
|
return { ...rest, checks: normalizedChecks };
|
||||||
|
}
|
||||||
|
return { ...monitor, checks: normalizedChecks };
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
statusPage,
|
||||||
|
monitors: normalizedMonitors,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
createStatusPage = async (req: Request, res: Response, next: NextFunction) => {
|
createStatusPage = async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
createStatusPageBodyValidation.parse(req.body);
|
createStatusPageBodyValidation.parse(req.body);
|
||||||
@@ -96,47 +135,44 @@ class StatusPageController implements IStatusPageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const statusPage = await this.statusPageService.getStatusPageByUrl(req.params.url as string);
|
const statusPage = await this.statusPageService.getStatusPageByUrl(req.params.url as string);
|
||||||
|
const data = await this.buildStatusPagePayload(statusPage, req);
|
||||||
|
|
||||||
if (!statusPage.isPublished) {
|
|
||||||
const teamId = requireTeamId(req?.user?.teamId);
|
|
||||||
if (statusPage.teamId !== teamId) {
|
|
||||||
throw new AppError({ message: "Forbidden", status: 403 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const settings = await this.settingsService.getDBSettings();
|
|
||||||
const showURL = settings.showURL;
|
|
||||||
|
|
||||||
const monitors = await this.monitorsRepository.findByIds(statusPage.monitors);
|
|
||||||
// Sort monitors according to the order in statusPage.monitors
|
|
||||||
const monitorOrder = new Map(statusPage.monitors.map((id, index) => [id, index]));
|
|
||||||
const sortedMonitors = [...monitors].sort((a, b) => {
|
|
||||||
const orderA = monitorOrder.get(a.id) ?? Number.MAX_SAFE_INTEGER;
|
|
||||||
const orderB = monitorOrder.get(b.id) ?? Number.MAX_SAFE_INTEGER;
|
|
||||||
return orderA - orderB;
|
|
||||||
});
|
|
||||||
|
|
||||||
const normalizedMonitors = sortedMonitors.map((monitor) => {
|
|
||||||
const normalizedChecks = NormalizeData(monitor.recentChecks, 10, 100);
|
|
||||||
if (!showURL) {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
const { url, port, secret, notifications, ...rest } = monitor;
|
|
||||||
return { ...rest, checks: normalizedChecks };
|
|
||||||
}
|
|
||||||
return { ...monitor, checks: normalizedChecks };
|
|
||||||
});
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: "Status page retrieved successfully",
|
msg: "Status page retrieved successfully",
|
||||||
data: {
|
data,
|
||||||
statusPage,
|
|
||||||
monitors: normalizedMonitors,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resolveStatusPageByDomain = async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
try {
|
||||||
|
resolveStatusPageQueryValidation.parse(req.query);
|
||||||
|
|
||||||
|
const domain = resolveStatusPageDomainFromRequest(req.hostname, req.query.domain as string | undefined);
|
||||||
|
if (!domain) {
|
||||||
|
throw new AppError({ message: "Domain is required", status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusPage = await this.statusPageService.getStatusPageByCustomDomain(domain);
|
||||||
|
if (!statusPage.isPublished) {
|
||||||
|
throw new AppError({ message: "Status page not found", status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await this.buildStatusPagePayload(statusPage, req);
|
||||||
|
|
||||||
|
return res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
msg: "Status page retrieved successfully",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
getStatusPagesByTeamId = async (req: Request, res: Response, next: NextFunction) => {
|
getStatusPagesByTeamId = async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const teamId = requireTeamId(req.user?.teamId);
|
const teamId = requireTeamId(req.user?.teamId);
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { DEFAULT_STATUS_PAGE_THEME, DEFAULT_STATUS_PAGE_THEME_MODE, type StatusPage } from "@/types/statusPage.js";
|
import { DEFAULT_STATUS_PAGE_THEME, DEFAULT_STATUS_PAGE_THEME_MODE, type StatusPage } from "@/domain/status-pages/status-page.type.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When STATUS_PAGE_THEMES_ENABLED is false, the controller drops incoming
|
* When STATUS_PAGE_THEMES_ENABLED is false, the controller drops incoming
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { ITagsService } from "@/service/index.js";
|
import { ITagsService } from "@/domain/tags/tag.service.js";
|
||||||
import { requireTeamId } from "./controllerUtils.js";
|
import { requireTeamId } from "./controllerUtils.js";
|
||||||
import {
|
import {
|
||||||
createTagBodyValidation,
|
createTagBodyValidation,
|
||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
getTagByIdParamValidation,
|
getTagByIdParamValidation,
|
||||||
editTagParamValidation,
|
editTagParamValidation,
|
||||||
deleteTagParamValidation,
|
deleteTagParamValidation,
|
||||||
} from "@/validation/index.js";
|
} from "@/api/validation/index.js";
|
||||||
|
|
||||||
export interface ITagsController {
|
export interface ITagsController {
|
||||||
createTag: (req: Request, res: Response, next: NextFunction) => Promise<Response | void>;
|
createTag: (req: Request, res: Response, next: NextFunction) => Promise<Response | void>;
|
||||||
Executable
+27
@@ -0,0 +1,27 @@
|
|||||||
|
import type { NextFunction, Request, Response } from "express";
|
||||||
|
import { MulterError } from "multer";
|
||||||
|
import type { ILogger } from "@/utils/logger.js";
|
||||||
|
import { AppError } from "@/utils/AppError.js";
|
||||||
|
|
||||||
|
// Multer throws MulterError, send 413 Payload Too Large / 400
|
||||||
|
const multerErrorStatus = (error: MulterError): number => (error.code === "LIMIT_FILE_SIZE" ? 413 : 400);
|
||||||
|
|
||||||
|
const handleErrors = (logger: ILogger) => (error: unknown, req: Request, res: Response, _next: NextFunction) => {
|
||||||
|
const status = error instanceof MulterError ? multerErrorStatus(error) : error instanceof AppError ? error.status || 500 : 500;
|
||||||
|
const message = error instanceof AppError ? error.message : error instanceof Error ? error.message : "Server error";
|
||||||
|
const service = error instanceof AppError ? error.service : error instanceof MulterError ? "uploadMiddleware" : "unknownService";
|
||||||
|
const method = error instanceof AppError ? error.method : "unknownMethod";
|
||||||
|
logger.error({
|
||||||
|
message: message,
|
||||||
|
service: service,
|
||||||
|
method: method,
|
||||||
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
|
details: error instanceof AppError ? error.details : undefined,
|
||||||
|
});
|
||||||
|
res.status(status).json({
|
||||||
|
status,
|
||||||
|
msg: message,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export { handleErrors };
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { Request, Response, NextFunction } from "express";
|
import type { Request, Response, NextFunction } from "express";
|
||||||
const SERVICE_NAME = "allowedRoles";
|
const SERVICE_NAME = "allowedRoles";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
import type { UserRole } from "@/types/index.js";
|
import type { UserRole } from "@/domain/users/user.type.js";
|
||||||
|
|
||||||
const isAllowed = (allowedRoles: UserRole[]) => {
|
const isAllowed = (allowedRoles: UserRole[]) => {
|
||||||
return (req: Request, res: Response, next: NextFunction) => {
|
return (req: Request, res: Response, next: NextFunction) => {
|
||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,68 @@
|
|||||||
|
import type { CorsOptions } from "cors";
|
||||||
|
import type { IStatusPagesRepository } from "@/domain/status-pages/status-page-repository.interface.js";
|
||||||
|
import { normalizeStatusPageDomain } from "@/utils/statusPageDomain.js";
|
||||||
|
|
||||||
|
const CUSTOM_DOMAIN_CORS_POSITIVE_CACHE_TTL_MS = 5 * 60 * 1000;
|
||||||
|
const CUSTOM_DOMAIN_CORS_NEGATIVE_CACHE_TTL_MS = 60 * 1000;
|
||||||
|
|
||||||
|
type CustomDomainCorsCacheEntry = {
|
||||||
|
allowed: boolean;
|
||||||
|
expiresAt: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getCustomDomainCorsCacheTtlMs = (allowed: boolean): number =>
|
||||||
|
allowed ? CUSTOM_DOMAIN_CORS_POSITIVE_CACHE_TTL_MS : CUSTOM_DOMAIN_CORS_NEGATIVE_CACHE_TTL_MS;
|
||||||
|
|
||||||
|
export const createStatusPageCorsOrigin = (clientHost: string, statusPagesRepository: IStatusPagesRepository): CorsOptions["origin"] => {
|
||||||
|
const cache = new Map<string, CustomDomainCorsCacheEntry>();
|
||||||
|
|
||||||
|
const cacheOriginResult = (customDomain: string, allowed: boolean) => {
|
||||||
|
cache.set(customDomain, {
|
||||||
|
allowed,
|
||||||
|
expiresAt: Date.now() + getCustomDomainCorsCacheTtlMs(allowed),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (origin, callback) => {
|
||||||
|
if (!origin) {
|
||||||
|
callback(null, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (origin === clientHost) {
|
||||||
|
callback(null, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let customDomain: string | null = null;
|
||||||
|
try {
|
||||||
|
customDomain = normalizeStatusPageDomain(new URL(origin).hostname);
|
||||||
|
} catch {
|
||||||
|
callback(null, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!customDomain) {
|
||||||
|
callback(null, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cached = cache.get(customDomain);
|
||||||
|
if (cached && cached.expiresAt > Date.now()) {
|
||||||
|
callback(null, cached.allowed ? origin : false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
statusPagesRepository
|
||||||
|
.findByCustomDomain(customDomain)
|
||||||
|
.then((statusPage) => {
|
||||||
|
const allowed = statusPage.isPublished;
|
||||||
|
cacheOriginResult(customDomain, allowed);
|
||||||
|
callback(null, allowed ? origin : false);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
cacheOriginResult(customDomain, false);
|
||||||
|
callback(null, false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
const PUBLIC_STATUS_PAGE_API_PREFIX = "/api/v1/status-page";
|
||||||
|
|
||||||
|
export const isPublicStatusPageApiPath = (method: string, path: string): boolean => {
|
||||||
|
if (!path.startsWith(PUBLIC_STATUS_PAGE_API_PREFIX)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method !== "GET" && method !== "OPTIONS") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const subPath = path.slice(PUBLIC_STATUS_PAGE_API_PREFIX.length).split("?")[0] ?? "";
|
||||||
|
const slug = subPath.replace(/^\//, "");
|
||||||
|
|
||||||
|
if (slug === "resolve") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!slug || slug === "team" || slug.includes("/")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import multer from "multer";
|
||||||
|
import { AppError } from "@/utils/AppError.js";
|
||||||
|
import { ImageMimeTypes, MAX_IMAGE_SIZE_BYTES } from "@/types/upload.js";
|
||||||
|
|
||||||
|
// Reusable multer instance for handling image uploads
|
||||||
|
const imageUpload = multer({
|
||||||
|
limits: {
|
||||||
|
fileSize: MAX_IMAGE_SIZE_BYTES,
|
||||||
|
files: 1,
|
||||||
|
},
|
||||||
|
fileFilter: (_req, file, cb) => {
|
||||||
|
if (!(ImageMimeTypes as readonly string[]).includes(file.mimetype)) {
|
||||||
|
cb(
|
||||||
|
new AppError({
|
||||||
|
status: 415,
|
||||||
|
message: "File must be a valid image (jpeg, jpg, or png)",
|
||||||
|
service: "uploadMiddleware",
|
||||||
|
method: "fileFilter",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cb(null, true);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export { imageUpload };
|
||||||
@@ -2,8 +2,8 @@ import { NextFunction, Request, Response } from "express";
|
|||||||
|
|
||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
import type { ISettingsService } from "@/service/system/settingsService.js";
|
import type { ISettingsService } from "@/domain/app-settings/app-settings.service.js";
|
||||||
import type { User } from "@/types/user.js";
|
import type { User } from "@/domain/users/user.type.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "verifyJWT";
|
const SERVICE_NAME = "verifyJWT";
|
||||||
const TOKEN_PREFIX = "Bearer ";
|
const TOKEN_PREFIX = "Bearer ";
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import { NextFunction, Request, RequestHandler, Response } from "express";
|
import { NextFunction, Request, RequestHandler, Response } from "express";
|
||||||
import { IStatusPagesRepository } from "@/repositories/index.js";
|
import { IStatusPagesRepository } from "@/domain/status-pages/status-page-repository.interface.js";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
|
|
||||||
export const createVerifyStatusPageAccess = (statusPagesRepository: IStatusPagesRepository, verifyJWT: RequestHandler) => {
|
export const createVerifyStatusPageAccess = (statusPagesRepository: IStatusPagesRepository, verifyJWT: RequestHandler) => {
|
||||||
Executable → Regular
+12
-8
@@ -1,9 +1,7 @@
|
|||||||
import { Router, RequestHandler } from "express";
|
import { Router, RequestHandler } from "express";
|
||||||
import { isAllowed } from "../middleware/isAllowed.js";
|
import { isAllowed } from "@/api/middleware/isAllowed.js";
|
||||||
import multer from "multer";
|
import { imageUpload } from "@/api/middleware/upload.js";
|
||||||
import { IAuthController } from "@/controllers/authController.js";
|
import { IAuthController } from "@/api/controllers/authController.js";
|
||||||
|
|
||||||
const upload = multer();
|
|
||||||
|
|
||||||
class AuthRoutes {
|
class AuthRoutes {
|
||||||
private router: Router;
|
private router: Router;
|
||||||
@@ -16,7 +14,7 @@ class AuthRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initRoutes(verifyJWT: RequestHandler) {
|
initRoutes(verifyJWT: RequestHandler) {
|
||||||
this.router.post("/register", upload.single("profileImage"), this.authController.registerUser);
|
this.router.post("/register", imageUpload.single("profileImage"), this.authController.registerUser);
|
||||||
this.router.post("/login", this.authController.loginUser);
|
this.router.post("/login", this.authController.loginUser);
|
||||||
|
|
||||||
this.router.post("/recovery/request", this.authController.requestRecovery);
|
this.router.post("/recovery/request", this.authController.requestRecovery);
|
||||||
@@ -26,13 +24,19 @@ class AuthRoutes {
|
|||||||
this.router.get("/users/superadmin", this.authController.checkSuperadminExists);
|
this.router.get("/users/superadmin", this.authController.checkSuperadminExists);
|
||||||
|
|
||||||
this.router.get("/users", verifyJWT, isAllowed(["admin", "superadmin"]), this.authController.getAllUsers);
|
this.router.get("/users", verifyJWT, isAllowed(["admin", "superadmin"]), this.authController.getAllUsers);
|
||||||
this.router.post("/users", verifyJWT, isAllowed(["superadmin"]), upload.single("profileImage"), this.authController.createUser);
|
this.router.post("/users", verifyJWT, isAllowed(["superadmin"]), imageUpload.single("profileImage"), this.authController.createUser);
|
||||||
this.router.get("/users/:userId", verifyJWT, isAllowed(["admin", "superadmin"]), this.authController.getUserById);
|
this.router.get("/users/:userId", verifyJWT, isAllowed(["admin", "superadmin"]), this.authController.getUserById);
|
||||||
this.router.patch("/users/:userId", verifyJWT, isAllowed(["superadmin"]), this.authController.editUserById);
|
this.router.patch("/users/:userId", verifyJWT, isAllowed(["superadmin"]), this.authController.editUserById);
|
||||||
this.router.patch("/users/:userId/password", verifyJWT, isAllowed(["superadmin"]), this.authController.editUserPasswordById);
|
this.router.patch("/users/:userId/password", verifyJWT, isAllowed(["superadmin"]), this.authController.editUserPasswordById);
|
||||||
this.router.delete("/users/:userId", verifyJWT, isAllowed(["admin", "superadmin"]), this.authController.deleteUserById);
|
this.router.delete("/users/:userId", verifyJWT, isAllowed(["admin", "superadmin"]), this.authController.deleteUserById);
|
||||||
|
|
||||||
this.router.patch("/user", verifyJWT, upload.single("profileImage"), isAllowed(["admin", "superadmin", "user"]), this.authController.editUser);
|
this.router.patch(
|
||||||
|
"/user",
|
||||||
|
verifyJWT,
|
||||||
|
imageUpload.single("profileImage"),
|
||||||
|
isAllowed(["admin", "superadmin", "user"]),
|
||||||
|
this.authController.editUser
|
||||||
|
);
|
||||||
this.router.delete("/user", verifyJWT, isAllowed(["admin", "superadmin", "user"]), this.authController.deleteUser);
|
this.router.delete("/user", verifyJWT, isAllowed(["admin", "superadmin", "user"]), this.authController.deleteUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
Executable → Regular
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
|
|
||||||
import { isAllowed } from "../middleware/isAllowed.js";
|
import { isAllowed } from "../middleware/isAllowed.js";
|
||||||
import { ICheckController } from "@/controllers/checkController.js";
|
import { ICheckController } from "@/api/controllers/checkController.js";
|
||||||
|
|
||||||
class CheckRoutes {
|
class CheckRoutes {
|
||||||
private router: Router;
|
private router: Router;
|
||||||
Executable → Regular
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { RequestHandler, Router } from "express";
|
import { RequestHandler, Router } from "express";
|
||||||
import { isAllowed } from "../middleware/isAllowed.js";
|
import { isAllowed } from "../middleware/isAllowed.js";
|
||||||
import { IDiagnosticController } from "@/controllers/diagnosticController.js";
|
import { IDiagnosticController } from "@/api/controllers/diagnosticController.js";
|
||||||
|
|
||||||
class DiagnosticRoutes {
|
class DiagnosticRoutes {
|
||||||
private router: Router;
|
private router: Router;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IGeoCheckController } from "@/controllers/geoCheckController.js";
|
import { IGeoCheckController } from "@/api/controllers/geoCheckController.js";
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
|
|
||||||
class GeoCheckRoutes {
|
class GeoCheckRoutes {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { isAllowed } from "../middleware/isAllowed.js";
|
import { isAllowed } from "../middleware/isAllowed.js";
|
||||||
import { IIncidentController } from "@/controllers/incidentController.js";
|
import { IIncidentController } from "@/api/controllers/incidentController.js";
|
||||||
|
|
||||||
class IncidentRoutes {
|
class IncidentRoutes {
|
||||||
private router: Router;
|
private router: Router;
|
||||||
Executable → Regular
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { RequestHandler, Router } from "express";
|
import { RequestHandler, Router } from "express";
|
||||||
import { isAllowed } from "../middleware/isAllowed.js";
|
import { isAllowed } from "../middleware/isAllowed.js";
|
||||||
import { IInviteController } from "@/controllers/inviteController.js";
|
import { IInviteController } from "@/api/controllers/inviteController.js";
|
||||||
|
|
||||||
class InviteRoutes {
|
class InviteRoutes {
|
||||||
private router: Router;
|
private router: Router;
|
||||||
Executable → Regular
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { isAllowed } from "@/middleware/isAllowed.js";
|
import { isAllowed } from "@/api/middleware/isAllowed.js";
|
||||||
import { ILogController } from "@/controllers/logController.js";
|
import { ILogController } from "@/api/controllers/logController.js";
|
||||||
class LogRoutes {
|
class LogRoutes {
|
||||||
private router: Router;
|
private router: Router;
|
||||||
private logController: ILogController;
|
private logController: ILogController;
|
||||||
Executable → Regular
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { IMaintenanceWindowController } from "@/controllers/maintenanceWindowController.js";
|
import { IMaintenanceWindowController } from "@/api/controllers/maintenanceWindowController.js";
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
|
|
||||||
class MaintenanceWindowRoutes {
|
class MaintenanceWindowRoutes {
|
||||||
Loaded 100 of 365 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user