Skip to content

Open-source status page, incident response and uptime monitoring

🥰 small improvments (#438)

Thibault Le Ouay122fde37fb03
diff --git a/apps/server/src/checker/checker.test.ts b/apps/server/src/checker/checker.test.ts
index 6e84d4d1b..225d4cae8 100644
--- a/apps/server/src/checker/checker.test.ts
+++ b/apps/server/src/checker/checker.test.ts
@@ -75,3 +75,72 @@ test("What should we do when redirect ", async () => {
}
expect(fn).toHaveBeenCalledTimes(0);
});
+
+test("When 404 we should trigger alerting ", async () => {
+ const fn = mock(() => {});
+ const fn1 = mock(() => {});
+ const fn2 = mock(() => {});
+
+ mock.module("./alerting.ts", () => {
+ return {
+ updateMonitorStatus: fn,
+ triggerAlerting: fn1,
+ };
+ });
+ mock.module("./ping.ts", () => {
+ return {
+ publishPing: fn2,
+ };
+ });
+ try {
+ await checkerRetryPolicy({
+ workspaceId: "1",
+ monitorId: "1",
+ url: "https://www.openstat.us/404",
+ cronTimestamp: 1,
+ status: "active",
+ pageIds: [],
+ method: "GET",
+ });
+ } catch (e) {
+ expect(e).toBeInstanceOf(Error);
+ }
+ expect(fn).toHaveBeenCalledTimes(1);
+ expect(fn1).toHaveBeenCalledTimes(1);
+ expect(fn2).toHaveBeenCalledTimes(1);
+});
+
+test("When error 404 we should not trigger alerting ", async () => {
+ const fn = mock(() => {});
+ const fn1 = mock(() => {});
+ const fn2 = mock(() => {});
+
+ mock.module("./alerting.ts", () => {
+ return {
+ updateMonitorStatus: fn,
+ triggerAlerting: fn1,
+ };
+ });
+
+ mock.module("./ping.ts", () => {
+ return {
+ publishPing: fn2,
+ };
+ });
+ try {
+ await checkerRetryPolicy({
+ workspaceId: "1",
+ monitorId: "1",
+ url: "https://www.openstat.us/404",
+ cronTimestamp: 1,
+ status: "error",
+ pageIds: [],
+ method: "GET",
+ });
+ } catch (e) {
+ expect(e).toBeInstanceOf(Error);
+ }
+ expect(fn).toHaveBeenCalledTimes(0);
+ expect(fn1).toHaveBeenCalledTimes(0);
+ expect(fn2).toHaveBeenCalledTimes(1);
+});
diff --git a/apps/server/src/v1/incident.ts b/apps/server/src/v1/incident.ts
index 6b861ee8c..1f7facdee 100644
--- a/apps/server/src/v1/incident.ts
+++ b/apps/server/src/v1/incident.ts
@@ -60,6 +60,7 @@ const incidentExtendedSchema = incidentSchema.extend({
const getAllRoute = createRoute({
method: "get",
tags: ["incident"],
+ description: "Get all incidents",
path: "/",
request: {},
responses: {
@@ -108,6 +109,7 @@ incidentApi.openapi(getAllRoute, async (c) => {
const getRoute = createRoute({
method: "get",
tags: ["incident"],
+ description: "Get an incident",
path: "/:id",
request: {
params: ParamsSchema,
@@ -162,6 +164,7 @@ incidentApi.openapi(getRoute, async (c) => {
const postRoute = createRoute({
method: "post",
tags: ["incident"],
+ description: "Create an incident",
path: "/",
request: {
body: {
@@ -214,6 +217,7 @@ incidentApi.openapi(postRoute, async (c) => {
const deleteRoute = createRoute({
method: "delete",
tags: ["incident"],
+ description: "Delete an incident",
path: "/:id",
request: {
params: ParamsSchema,
@@ -266,10 +270,11 @@ const postRouteUpdate = createRoute({
method: "post",
tags: ["incident"],
path: "/:id/update",
+ description: "Create an incident update",
request: {
params: ParamsSchema,
body: {
- description: "The incident to update",
+ description: "the incident update",
content: {
"application/json": {
schema: incidentUpdateSchema,
diff --git a/apps/server/src/v1/monitor.ts b/apps/server/src/v1/monitor.ts
index 98b6cc54c..01bb5877e 100644
--- a/apps/server/src/v1/monitor.ts
+++ b/apps/server/src/v1/monitor.ts
@@ -153,6 +153,7 @@ const monitorApi = new OpenAPIHono<{ Variables: Variables }>();
const getAllRoute = createRoute({
method: "get",
tags: ["monitor"],
+ description: "Get all monitors",
path: "/",
request: {},
responses: {
@@ -162,7 +163,7 @@ const getAllRoute = createRoute({
schema: z.array(MonitorSchema),
},
},
- description: "Get the monitor",
+ description: "All the monitors",
},
404: {
content: {
@@ -201,6 +202,7 @@ monitorApi.openapi(getAllRoute, async (c) => {
const getRoute = createRoute({
method: "get",
tags: ["monitor"],
+ description: "Get a monitor",
path: "/:id",
request: {
params: ParamsSchema,
@@ -212,7 +214,7 @@ const getRoute = createRoute({
schema: MonitorSchema,
},
},
- description: "Get the monitor",
+ description: "The monitor",
},
401: {
content: {
@@ -258,6 +260,7 @@ monitorApi.openapi(getRoute, async (c) => {
const postRoute = createRoute({
method: "post",
tags: ["monitor"],
+ description: "Create a monitor",
path: "/",
request: {
body: {
@@ -332,6 +335,7 @@ monitorApi.openapi(postRoute, async (c) => {
const putRoute = createRoute({
method: "put",
tags: ["monitor"],
+ description: "Update a monitor",
path: "/:id",
request: {
params: ParamsSchema,
@@ -404,6 +408,7 @@ monitorApi.openapi(putRoute, async (c) => {
const deleteRoute = createRoute({
method: "delete",
tags: ["monitor"],
+ description: "Delete a monitor",
path: "/:id",
request: {
params: ParamsSchema,
diff --git a/packages/emails/emails/waiting-list.tsx b/packages/emails/emails/waiting-list.tsx
index 82c646a6c..eccbc75ec 100644
--- a/packages/emails/emails/waiting-list.tsx
+++ b/packages/emails/emails/waiting-list.tsx
@@ -5,9 +5,7 @@ const WaitingList = () => {
<Html>
<Head>
<title>Thanks for joining OpenStatus waiting list</title>
- <Preview>
- Thanks for joining OpenStatus waiting list
- </Preview>
+ <Preview>Thanks for joining OpenStatus waiting list</Preview>
<Body>
Hello,
<br />