diff --git a/apps/screenshot-service/src/index.ts b/apps/screenshot-service/src/index.ts index 4df944f3d6..19f764e264 100644 --- a/apps/screenshot-service/src/index.ts +++ b/apps/screenshot-service/src/index.ts @@ -27,7 +27,7 @@ const receiver = new Receiver({ const app = new Hono(); app.get("/ping", (c) => - c.json({ ping: "pong", region: process.env.FLY_REGION }, 200) + c.json({ ping: "pong", region: process.env.FLY_REGION }, 200), ); app.post( @@ -38,7 +38,7 @@ app.post( url: z.string().url(), incidentId: z.number(), kind: z.enum(["incident", "recovery"]), - }) + }), ), async (c) => { const signature = c.req.header("Upstash-Signature"); @@ -53,7 +53,6 @@ app.post( body: JSON.stringify(data), }); if (!isValid) { - console.error("Unauthorized"); return c.text("Unauthorized", 401); } @@ -75,7 +74,7 @@ app.post( Bucket: "incident-screenshot", Key: id, ContentType: "image/png", - }) + }), ); if (data.kind === "incident") { @@ -109,7 +108,7 @@ app.post( } return c.text("Screenshot saved"); - } + }, ); export default app; diff --git a/apps/server/src/checker/index.ts b/apps/server/src/checker/index.ts index 02a9e6fea7..8ccda2f6a2 100644 --- a/apps/server/src/checker/index.ts +++ b/apps/server/src/checker/index.ts @@ -1,6 +1,6 @@ +import { Client } from "@upstash/qstash"; import { Hono } from "hono"; import { z } from "zod"; -import { Client } from "@upstash/qstash"; import { and, db, eq, isNull, schema } from "@openstatus/db"; import { incidentTable } from "@openstatus/db/src/schema"; @@ -59,8 +59,8 @@ checkerRoute.post("/updateStatus", async (c) => { and( eq(incidentTable.monitorId, Number(monitorId)), isNull(incidentTable.resolvedAt), - isNull(incidentTable.acknowledgedAt) - ) + isNull(incidentTable.acknowledgedAt), + ), ) .get(); @@ -100,7 +100,7 @@ checkerRoute.post("/updateStatus", async (c) => { const numberOfRegions = monitor.regions.length; console.log( - `🤓 MonitorID ${monitorId} incident current affected ${nbAffectedRegion} total region ${numberOfRegions}` + `🤓 MonitorID ${monitorId} incident current affected ${nbAffectedRegion} total region ${numberOfRegions}`, ); // If the number of affected regions is greater than half of the total region, we trigger the alerting // 4 of 6 monitor need to fail to trigger an alerting @@ -114,8 +114,8 @@ checkerRoute.post("/updateStatus", async (c) => { eq(incidentTable.monitorId, Number(monitorId)), isNull(incidentTable.resolvedAt), isNull(incidentTable.acknowledgedAt), - eq(incidentTable.startedAt, new Date(cronTimestamp)) - ) + eq(incidentTable.startedAt, new Date(cronTimestamp)), + ), ) .get(); @@ -192,7 +192,7 @@ checkerRoute.post("/updateStatus", async (c) => { const numberOfRegions = monitor.regions.length; console.log( - `🤓 MonitorId ${monitorId} recovering incident current ${nbAffectedRegion} total region ${numberOfRegions}` + `🤓 MonitorId ${monitorId} recovering incident current ${nbAffectedRegion} total region ${numberOfRegions}`, ); // // If the number of affected regions is greater than half of the total region, we trigger the alerting // // 4 of 6 monitor need to fail to trigger an alerting @@ -204,8 +204,8 @@ checkerRoute.post("/updateStatus", async (c) => { and( eq(incidentTable.monitorId, Number(monitorId)), isNull(incidentTable.resolvedAt), - isNull(incidentTable.acknowledgedAt) - ) + isNull(incidentTable.acknowledgedAt), + ), ) .get(); if (incident) { diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index 8e9b669c93..082c764443 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -5,9 +5,9 @@ import { logger } from "hono/logger"; import { checkerRoute } from "./checker"; import { env } from "./env"; +import { handleError } from "./libs/errors"; import { publicRoute } from "./public"; import { api } from "./v1"; -import { handleError } from "./libs/errors"; const app = new Hono({ strict: false }); app.use("*", sentry({ dsn: process.env.SENTRY_DSN })); diff --git a/apps/server/src/libs/errors/openapi-error-responses.ts b/apps/server/src/libs/errors/openapi-error-responses.ts index bcc3342ea0..9b1863a72a 100644 --- a/apps/server/src/libs/errors/openapi-error-responses.ts +++ b/apps/server/src/libs/errors/openapi-error-responses.ts @@ -51,7 +51,7 @@ export const openApiErrorResponses = { content: { "application/json": { schema: createErrorSchema("INTERNAL_SERVER_ERROR").openapi( - "ErrInternalServerError" + "ErrInternalServerError", ), }, }, diff --git a/apps/server/src/libs/errors/utils.ts b/apps/server/src/libs/errors/utils.ts index a5375b1891..0490fedf5a 100644 --- a/apps/server/src/libs/errors/utils.ts +++ b/apps/server/src/libs/errors/utils.ts @@ -19,7 +19,7 @@ export function handleError(err: Error, c: Context): Response { message: error.message, docs: "https://docs.openstatus.dev/api-references/errors/code/BAD_REQUEST", }, - { status: 400 } + { status: 400 }, ); } if (err instanceof HTTPException) { @@ -30,7 +30,7 @@ export function handleError(err: Error, c: Context): Response { message: err.message, docs: `https://docs.openstatus.dev/api-references/errors/code/${code}`, }, - { status: err.status } + { status: err.status }, ); } return c.json( @@ -40,7 +40,7 @@ export function handleError(err: Error, c: Context): Response { docs: "https://docs.openstatus.dev/api-references/errors/code/INTERNAL_SERVER_ERROR", }, - { status: 500 } + { status: 500 }, ); } @@ -54,7 +54,7 @@ export function handleZodError( success: false; error: ZodError; }, - c: Context + c: Context, ) { if (!result.success) { const error = SchemaError.fromZod(result.error, c); @@ -64,7 +64,7 @@ export function handleZodError( docs: "https://docs.openstatus.dev/api-references/errors/code/BAD_REQUEST", message: error.message, }, - { status: 400 } + { status: 400 }, ); } } diff --git a/apps/server/src/public/status.ts b/apps/server/src/public/status.ts index 42a1a43892..aecc19c3ee 100644 --- a/apps/server/src/public/status.ts +++ b/apps/server/src/public/status.ts @@ -84,8 +84,8 @@ async function getStatusPageData(pageId: number) { and( eq(monitorsToPages.monitorId, monitor.id), eq(monitor.active, true), - eq(monitorsToPages.pageId, pageId) - ) + eq(monitorsToPages.pageId, pageId), + ), ) .all(); @@ -105,7 +105,7 @@ async function getStatusPageData(pageId: number) { .from(monitorsToStatusReport) .innerJoin( statusReport, - eq(monitorsToStatusReport.statusReportId, statusReport.id) + eq(monitorsToStatusReport.statusReportId, statusReport.id), ) .where(inArray(monitorsToStatusReport.monitorId, monitorIds)) .all(); @@ -117,8 +117,8 @@ async function getStatusPageData(pageId: number) { statusReport, and( eq(pagesToStatusReports.statusReportId, statusReport.id), - eq(pagesToStatusReports.pageId, pageId) - ) + eq(pagesToStatusReports.pageId, pageId), + ), ) .all(); @@ -128,8 +128,8 @@ async function getStatusPageData(pageId: number) { .where( and( isNull(incidentTable.resolvedAt), - inArray(incidentTable.monitorId, monitorIds) - ) + inArray(incidentTable.monitorId, monitorIds), + ), ) .all(); @@ -140,8 +140,8 @@ async function getStatusPageData(pageId: number) { and( eq(maintenance.pageId, pageId), lte(maintenance.from, new Date()), - gte(maintenance.to, new Date()) - ) + gte(maintenance.to, new Date()), + ), ); const [ diff --git a/apps/server/src/v1/incidents/get.ts b/apps/server/src/v1/incidents/get.ts index eba1952b1b..49a5f937d9 100644 --- a/apps/server/src/v1/incidents/get.ts +++ b/apps/server/src/v1/incidents/get.ts @@ -3,10 +3,10 @@ import { createRoute } from "@hono/zod-openapi"; import { and, db, eq } from "@openstatus/db"; import { incidentTable } from "@openstatus/db/src/schema/incidents"; -import { IncidentSchema, ParamsSchema } from "./schema"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { incidentsApi } from "./index"; -import { HTTPException } from "hono/http-exception"; +import { IncidentSchema, ParamsSchema } from "./schema"; const getRoute = createRoute({ method: "get", diff --git a/apps/server/src/v1/incidents/get_all.ts b/apps/server/src/v1/incidents/get_all.ts index e9218cd4fe..58ed41f829 100644 --- a/apps/server/src/v1/incidents/get_all.ts +++ b/apps/server/src/v1/incidents/get_all.ts @@ -3,10 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi"; import { db, eq } from "@openstatus/db"; import { incidentTable } from "@openstatus/db/src/schema/incidents"; -import { IncidentSchema } from "./schema"; -import type { incidentsApi } from "./index"; -import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; +import type { incidentsApi } from "./index"; +import { IncidentSchema } from "./schema"; const getAllRoute = createRoute({ method: "get", diff --git a/apps/server/src/v1/incidents/index.ts b/apps/server/src/v1/incidents/index.ts index ccce567e5c..8385c12bf9 100644 --- a/apps/server/src/v1/incidents/index.ts +++ b/apps/server/src/v1/incidents/index.ts @@ -1,10 +1,10 @@ import { OpenAPIHono } from "@hono/zod-openapi"; +import { handleZodError } from "../../libs/errors"; import type { Variables } from "../index"; -import { registerGetAllIncidents } from "./get_all"; import { registerGetIncident } from "./get"; +import { registerGetAllIncidents } from "./get_all"; import { registerPutIncident } from "./put"; -import { handleZodError } from "../../libs/errors"; const incidentsApi = new OpenAPIHono<{ Variables: Variables }>({ defaultHook: handleZodError, diff --git a/apps/server/src/v1/incidents/put.ts b/apps/server/src/v1/incidents/put.ts index 473aa2e917..8ab89c68c5 100644 --- a/apps/server/src/v1/incidents/put.ts +++ b/apps/server/src/v1/incidents/put.ts @@ -3,10 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi"; import { and, db, eq } from "@openstatus/db"; import { incidentTable } from "@openstatus/db/src/schema/incidents"; -import { IncidentSchema, ParamsSchema } from "./schema"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { incidentsApi } from "./index"; -import { HTTPException } from "hono/http-exception"; +import { IncidentSchema, ParamsSchema } from "./schema"; const putRoute = createRoute({ method: "put", @@ -59,8 +59,8 @@ export function registerPutIncident(app: typeof incidentsApi) { .where( and( eq(incidentTable.id, Number(id)), - eq(incidentTable.workspaceId, Number(workspaceId)) - ) + eq(incidentTable.workspaceId, Number(workspaceId)), + ), ) .get(); diff --git a/apps/server/src/v1/index.ts b/apps/server/src/v1/index.ts index 6dce816cbc..aabd5d76f5 100644 --- a/apps/server/src/v1/index.ts +++ b/apps/server/src/v1/index.ts @@ -4,15 +4,15 @@ import { logger } from "hono/logger"; import type { Limits } from "@openstatus/plans/src/types"; +import { handleError, handleZodError } from "../libs/errors"; import { incidentsApi } from "./incidents"; import { middleware } from "./middleware"; import { monitorsApi } from "./monitors"; import { notificationsApi } from "./notifications"; -import { pagesApi } from "./pages"; import { pageSubscribersApi } from "./pageSubscribers"; -import { statusReportsApi } from "./statusReports"; +import { pagesApi } from "./pages"; import { statusReportUpdatesApi } from "./statusReportUpdates"; -import { handleError, handleZodError } from "../libs/errors"; +import { statusReportsApi } from "./statusReports"; export type Variables = { workspaceId: string; diff --git a/apps/server/src/v1/middleware.ts b/apps/server/src/v1/middleware.ts index 9a78547ee9..312e6c3cfc 100644 --- a/apps/server/src/v1/middleware.ts +++ b/apps/server/src/v1/middleware.ts @@ -1,14 +1,14 @@ import { verifyKey } from "@unkey/api"; import type { Context, Next } from "hono"; -import type { Variables } from "./index"; -import { workspace } from "@openstatus/db/src/schema"; import { db, eq } from "@openstatus/db"; +import { workspace } from "@openstatus/db/src/schema"; import { getPlanConfig } from "@openstatus/plans"; +import type { Variables } from "./index"; export async function middleware( c: Context<{ Variables: Variables }, "/*">, - next: Next + next: Next, ) { const key = c.req.header("x-openstatus-key"); if (!key) return c.text("Unauthorized", 401); diff --git a/apps/server/src/v1/monitors/delete.ts b/apps/server/src/v1/monitors/delete.ts index 21feb562e5..2a33c75cdb 100644 --- a/apps/server/src/v1/monitors/delete.ts +++ b/apps/server/src/v1/monitors/delete.ts @@ -3,10 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi"; import { db, eq } from "@openstatus/db"; import { monitor } from "@openstatus/db/src/schema"; -import { ParamsSchema } from "./schema"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { monitorsApi } from "./index"; -import { HTTPException } from "hono/http-exception"; +import { ParamsSchema } from "./schema"; const deleteRoute = createRoute({ method: "delete", diff --git a/apps/server/src/v1/monitors/get.ts b/apps/server/src/v1/monitors/get.ts index 7b58e11671..7e40113eec 100644 --- a/apps/server/src/v1/monitors/get.ts +++ b/apps/server/src/v1/monitors/get.ts @@ -3,10 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi"; import { and, db, eq, isNull } from "@openstatus/db"; import { monitor } from "@openstatus/db/src/schema"; +import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { monitorsApi } from "./index"; import { MonitorSchema, ParamsSchema } from "./schema"; -import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; -import { HTTPException } from "hono/http-exception"; const getRoute = createRoute({ method: "get", @@ -41,8 +41,8 @@ export function registerGetMonitor(api: typeof monitorsApi) { and( eq(monitor.id, Number(id)), eq(monitor.workspaceId, Number(workspaceId)), - isNull(monitor.deletedAt) - ) + isNull(monitor.deletedAt), + ), ) .get(); diff --git a/apps/server/src/v1/monitors/get_all.ts b/apps/server/src/v1/monitors/get_all.ts index 283933fc00..fa56ef18d3 100644 --- a/apps/server/src/v1/monitors/get_all.ts +++ b/apps/server/src/v1/monitors/get_all.ts @@ -3,10 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi"; import { and, db, eq, isNull } from "@openstatus/db"; import { monitor } from "@openstatus/db/src/schema"; +import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { monitorsApi } from "./index"; import { MonitorSchema } from "./schema"; -import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; -import { HTTPException } from "hono/http-exception"; const getAllRoute = createRoute({ method: "get", @@ -37,8 +37,8 @@ export function registerGetAllMonitors(app: typeof monitorsApi) { .where( and( eq(monitor.workspaceId, Number(workspaceId)), - isNull(monitor.deletedAt) - ) + isNull(monitor.deletedAt), + ), ) .all(); diff --git a/apps/server/src/v1/monitors/index.ts b/apps/server/src/v1/monitors/index.ts index 1ad342c961..20352a8c4e 100644 --- a/apps/server/src/v1/monitors/index.ts +++ b/apps/server/src/v1/monitors/index.ts @@ -1,13 +1,13 @@ import { OpenAPIHono } from "@hono/zod-openapi"; +import { handleZodError } from "../../libs/errors"; import type { Variables } from "../index"; -import { registerGetAllMonitors } from "./get_all"; +import { registerDeleteMonitor } from "./delete"; import { registerGetMonitor } from "./get"; +import { registerGetAllMonitors } from "./get_all"; +import { registerPostMonitor } from "./post"; import { registerPutMonitor } from "./put"; -import { registerDeleteMonitor } from "./delete"; import { registerGetMonitorSummary } from "./summary/get"; -import { registerPostMonitor } from "./post"; -import { handleZodError } from "../../libs/errors"; const monitorsApi = new OpenAPIHono<{ Variables: Variables }>({ defaultHook: handleZodError, diff --git a/apps/server/src/v1/monitors/post.ts b/apps/server/src/v1/monitors/post.ts index e0be1a8eed..111913e4dd 100644 --- a/apps/server/src/v1/monitors/post.ts +++ b/apps/server/src/v1/monitors/post.ts @@ -4,11 +4,11 @@ import { trackAnalytics } from "@openstatus/analytics"; import { and, db, eq, isNull, sql } from "@openstatus/db"; import { monitor } from "@openstatus/db/src/schema"; -import type { monitorsApi } from "./index"; +import { HTTPException } from "hono/http-exception"; +import { env } from "../../env"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; +import type { monitorsApi } from "./index"; import { MonitorSchema } from "./schema"; -import { env } from "../../env"; -import { HTTPException } from "hono/http-exception"; const postRoute = createRoute({ method: "post", @@ -51,8 +51,8 @@ export function registerPostMonitor(api: typeof monitorsApi) { .where( and( eq(monitor.workspaceId, Number(workspaceId)), - isNull(monitor.deletedAt) - ) + isNull(monitor.deletedAt), + ), ) .all() )[0].count; diff --git a/apps/server/src/v1/monitors/put.ts b/apps/server/src/v1/monitors/put.ts index 6af2be5e86..0610a30291 100644 --- a/apps/server/src/v1/monitors/put.ts +++ b/apps/server/src/v1/monitors/put.ts @@ -3,10 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi"; import { db, eq } from "@openstatus/db"; import { monitor } from "@openstatus/db/src/schema"; -import { MonitorSchema, ParamsSchema } from "./schema"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { monitorsApi } from "./index"; -import { HTTPException } from "hono/http-exception"; +import { MonitorSchema, ParamsSchema } from "./schema"; const putRoute = createRoute({ method: "put", diff --git a/apps/server/src/v1/monitors/schema.ts b/apps/server/src/v1/monitors/schema.ts index 3b1b66df8c..e36394d002 100644 --- a/apps/server/src/v1/monitors/schema.ts +++ b/apps/server/src/v1/monitors/schema.ts @@ -36,23 +36,26 @@ export const MonitorSchema = z description: "The url to monitor", }), regions: z - .preprocess((val) => { - try { - if (Array.isArray(val)) return val; - if (String(val).length > 0) { - return String(val).split(","); + .preprocess( + (val) => { + try { + if (Array.isArray(val)) return val; + if (String(val).length > 0) { + return String(val).split(","); + } + return []; + } catch (e) { + throw new ZodError([ + { + code: "custom", + path: ["headers"], + message: e instanceof Error ? e.message : "Invalid value", + }, + ]); } - return []; - } catch (e) { - throw new ZodError([ - { - code: "custom", - path: ["headers"], - message: e instanceof Error ? e.message : "Invalid value", - }, - ]); - } - }, z.array(z.enum(flyRegions))) + }, + z.array(z.enum(flyRegions)), + ) .default([]) .openapi({ example: ["ams"], @@ -81,23 +84,26 @@ export const MonitorSchema = z description: "The body", }), headers: z - .preprocess((val) => { - try { - if (Array.isArray(val)) return val; - if (String(val).length > 0) { - return JSON.parse(String(val)); + .preprocess( + (val) => { + try { + if (Array.isArray(val)) return val; + if (String(val).length > 0) { + return JSON.parse(String(val)); + } + return []; + } catch (e) { + throw new ZodError([ + { + code: "custom", + path: ["headers"], + message: e instanceof Error ? e.message : "Invalid value", + }, + ]); } - return []; - } catch (e) { - throw new ZodError([ - { - code: "custom", - path: ["headers"], - message: e instanceof Error ? e.message : "Invalid value", - }, - ]); - } - }, z.array(z.object({ key: z.string(), value: z.string() })).default([])) + }, + z.array(z.object({ key: z.string(), value: z.string() })).default([]), + ) .nullish() .openapi({ description: "The headers of your request", diff --git a/apps/server/src/v1/monitors/summary/get.ts b/apps/server/src/v1/monitors/summary/get.ts index e0dcd1f1a3..715e548565 100644 --- a/apps/server/src/v1/monitors/summary/get.ts +++ b/apps/server/src/v1/monitors/summary/get.ts @@ -5,12 +5,12 @@ import { monitor } from "@openstatus/db/src/schema"; import { OSTinybird } from "@openstatus/tinybird"; import { Redis } from "@openstatus/upstash"; -import { isoDate } from "../../utils"; +import { HTTPException } from "hono/http-exception"; import { env } from "../../../env"; -import { ParamsSchema } from "../schema"; import { openApiErrorResponses } from "../../../libs/errors/openapi-error-responses"; +import { isoDate } from "../../utils"; import type { monitorsApi } from "../index"; -import { HTTPException } from "hono/http-exception"; +import { ParamsSchema } from "../schema"; const tb = new OSTinybird({ token: env.TINY_BIRD_API_KEY }); const redis = Redis.fromEnv(); @@ -65,8 +65,8 @@ export function registerGetMonitorSummary(api: typeof monitorsApi) { and( eq(monitor.id, Number(id)), eq(monitor.workspaceId, Number(workspaceId)), - isNull(monitor.deletedAt) - ) + isNull(monitor.deletedAt), + ), ) .get(); @@ -75,7 +75,7 @@ export function registerGetMonitorSummary(api: typeof monitorsApi) { } const cache = await redis.get>( - `${id}-daily-stats` + `${id}-daily-stats`, ); if (cache) { console.log("fetching from cache"); diff --git a/apps/server/src/v1/notifications/get.ts b/apps/server/src/v1/notifications/get.ts index 5d0a339b71..af4dfbc7fb 100644 --- a/apps/server/src/v1/notifications/get.ts +++ b/apps/server/src/v1/notifications/get.ts @@ -6,10 +6,10 @@ import { notificationsToMonitors, page, } from "@openstatus/db/src/schema"; -import { NotificationSchema, ParamsSchema } from "./schema"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { notificationsApi } from "./index"; -import { HTTPException } from "hono/http-exception"; +import { NotificationSchema, ParamsSchema } from "./schema"; const getRoute = createRoute({ method: "get", diff --git a/apps/server/src/v1/notifications/get_all.ts b/apps/server/src/v1/notifications/get_all.ts index 7316dea7c1..2f94e29e54 100644 --- a/apps/server/src/v1/notifications/get_all.ts +++ b/apps/server/src/v1/notifications/get_all.ts @@ -6,10 +6,10 @@ import { notificationsToMonitors, page, } from "@openstatus/db/src/schema"; -import { NotificationSchema } from "./schema"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { notificationsApi } from "./index"; -import { HTTPException } from "hono/http-exception"; +import { NotificationSchema } from "./schema"; const getAllRoute = createRoute({ method: "get", diff --git a/apps/server/src/v1/notifications/index.ts b/apps/server/src/v1/notifications/index.ts index 4ca08dd2fe..9666cba809 100644 --- a/apps/server/src/v1/notifications/index.ts +++ b/apps/server/src/v1/notifications/index.ts @@ -1,10 +1,10 @@ import { OpenAPIHono } from "@hono/zod-openapi"; +import { handleZodError } from "../../libs/errors"; import type { Variables } from "../index"; -import { registerGetAllNotifications } from "./get_all"; import { registerGetNotification } from "./get"; +import { registerGetAllNotifications } from "./get_all"; import { registerPostNotification } from "./post"; -import { handleZodError } from "../../libs/errors"; export const notificationsApi = new OpenAPIHono<{ Variables: Variables }>({ defaultHook: handleZodError, diff --git a/apps/server/src/v1/notifications/post.ts b/apps/server/src/v1/notifications/post.ts index cba2a69350..a21cb1e944 100644 --- a/apps/server/src/v1/notifications/post.ts +++ b/apps/server/src/v1/notifications/post.ts @@ -8,10 +8,10 @@ import { notificationsToMonitors, selectNotificationSchema, } from "@openstatus/db/src/schema"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; -import { NotificationSchema } from "./schema"; import type { notificationsApi } from "./index"; -import { HTTPException } from "hono/http-exception"; +import { NotificationSchema } from "./schema"; const postRoute = createRoute({ method: "post", @@ -75,8 +75,8 @@ export function registerPostNotification(api: typeof notificationsApi) { and( inArray(monitor.id, monitors), eq(monitor.workspaceId, Number(workspaceId)), - isNull(monitor.deletedAt) - ) + isNull(monitor.deletedAt), + ), ) .all(); diff --git a/apps/server/src/v1/pageSubscribers/index.ts b/apps/server/src/v1/pageSubscribers/index.ts index 35920aab77..1bf82be613 100644 --- a/apps/server/src/v1/pageSubscribers/index.ts +++ b/apps/server/src/v1/pageSubscribers/index.ts @@ -1,8 +1,8 @@ import { OpenAPIHono } from "@hono/zod-openapi"; +import { handleZodError } from "../../libs/errors"; import type { Variables } from "../index"; import { registerPostPageSubscriber } from "./post"; -import { handleZodError } from "../../libs/errors"; export const pageSubscribersApi = new OpenAPIHono<{ Variables: Variables }>({ defaultHook: handleZodError, diff --git a/apps/server/src/v1/pageSubscribers/post.ts b/apps/server/src/v1/pageSubscribers/post.ts index d9aec3f6d3..e7faf2e754 100644 --- a/apps/server/src/v1/pageSubscribers/post.ts +++ b/apps/server/src/v1/pageSubscribers/post.ts @@ -5,10 +5,10 @@ import { db } from "@openstatus/db/src/db"; import { page, pageSubscriber } from "@openstatus/db/src/schema"; import { SubscribeEmail } from "@openstatus/emails"; import { sendEmail } from "@openstatus/emails/emails/send"; -import { PageSubscriberSchema, ParamsSchema } from "./schema"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { pageSubscribersApi } from "./index"; -import { HTTPException } from "hono/http-exception"; +import { PageSubscriberSchema, ParamsSchema } from "./schema"; const postRouteSubscriber = createRoute({ method: "post", @@ -49,7 +49,7 @@ export function registerPostPageSubscriber(api: typeof pageSubscribersApi) { .select() .from(page) .where( - and(eq(page.id, Number(id)), eq(page.workspaceId, Number(workspaceId))) + and(eq(page.id, Number(id)), eq(page.workspaceId, Number(workspaceId))), ) .get(); @@ -63,8 +63,8 @@ export function registerPostPageSubscriber(api: typeof pageSubscribersApi) { .where( and( eq(pageSubscriber.email, input.email), - eq(pageSubscriber.pageId, Number(id)) - ) + eq(pageSubscriber.pageId, Number(id)), + ), ) .get(); diff --git a/apps/server/src/v1/pages/get.ts b/apps/server/src/v1/pages/get.ts index 5979876d42..6a20f4cf32 100644 --- a/apps/server/src/v1/pages/get.ts +++ b/apps/server/src/v1/pages/get.ts @@ -3,10 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi"; import { and, eq } from "@openstatus/db"; import { db } from "@openstatus/db/src/db"; import { page } from "@openstatus/db/src/schema"; -import { PageSchema, ParamsSchema } from "./schema"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { pagesApi } from "./index"; -import { HTTPException } from "hono/http-exception"; +import { PageSchema, ParamsSchema } from "./schema"; const getRoute = createRoute({ method: "get", diff --git a/apps/server/src/v1/pages/get_all.ts b/apps/server/src/v1/pages/get_all.ts index aec44c4698..d18cf3b907 100644 --- a/apps/server/src/v1/pages/get_all.ts +++ b/apps/server/src/v1/pages/get_all.ts @@ -1,11 +1,11 @@ import { createRoute, z } from "@hono/zod-openapi"; -import type { pagesApi } from "./index"; -import { PageSchema } from "./schema"; -import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import { db, eq } from "@openstatus/db"; import { page } from "@openstatus/db/src/schema"; import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; +import type { pagesApi } from "./index"; +import { PageSchema } from "./schema"; const getAllRoute = createRoute({ method: "get", diff --git a/apps/server/src/v1/pages/index.ts b/apps/server/src/v1/pages/index.ts index 3af40d50be..9cc8ebbc86 100644 --- a/apps/server/src/v1/pages/index.ts +++ b/apps/server/src/v1/pages/index.ts @@ -1,11 +1,11 @@ import { OpenAPIHono } from "@hono/zod-openapi"; +import { handleZodError } from "../../libs/errors"; import type { Variables } from "../index"; import { registerGetPage } from "./get"; import { registerGetAllPages } from "./get_all"; -import { registerPutPage } from "./put"; import { registerPostPage } from "./post"; -import { handleZodError } from "../../libs/errors"; +import { registerPutPage } from "./put"; export const pagesApi = new OpenAPIHono<{ Variables: Variables }>({ defaultHook: handleZodError, diff --git a/apps/server/src/v1/pages/post.ts b/apps/server/src/v1/pages/post.ts index 8318cc2397..5b88013d64 100644 --- a/apps/server/src/v1/pages/post.ts +++ b/apps/server/src/v1/pages/post.ts @@ -4,11 +4,11 @@ import { and, eq, inArray, isNull, sql } from "@openstatus/db"; import { db } from "@openstatus/db/src/db"; import { monitor, monitorsToPages, page } from "@openstatus/db/src/schema"; -import type { pagesApi } from "./index"; -import { isNumberArray } from "../utils"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; +import { isNumberArray } from "../utils"; +import type { pagesApi } from "./index"; import { PageSchema } from "./schema"; -import { HTTPException } from "hono/http-exception"; const postRoute = createRoute({ method: "post", @@ -95,8 +95,8 @@ export function registerPostPage(api: typeof pagesApi) { and( inArray(monitor.id, monitorIds), eq(monitor.workspaceId, Number(workspaceId)), - isNull(monitor.deletedAt) - ) + isNull(monitor.deletedAt), + ), ) .all(); diff --git a/apps/server/src/v1/pages/put.ts b/apps/server/src/v1/pages/put.ts index eee4da97e9..3a8cb5a207 100644 --- a/apps/server/src/v1/pages/put.ts +++ b/apps/server/src/v1/pages/put.ts @@ -3,11 +3,11 @@ import { createRoute } from "@hono/zod-openapi"; import { and, eq, inArray, isNull, sql } from "@openstatus/db"; import { db } from "@openstatus/db/src/db"; import { monitor, monitorsToPages, page } from "@openstatus/db/src/schema"; -import { PageSchema, ParamsSchema } from "./schema"; +import { HTTPException } from "hono/http-exception"; import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; -import type { pagesApi } from "./index"; import { isNumberArray } from "../utils"; -import { HTTPException } from "hono/http-exception"; +import type { pagesApi } from "./index"; +import { PageSchema, ParamsSchema } from "./schema"; const putRoute = createRoute({ method: "put", @@ -59,7 +59,7 @@ export function registerPutPage(api: typeof pagesApi) { .select() .from(page) .where( - and(eq(page.id, Number(id)), eq(page.workspaceId, Number(workspaceId))) + and(eq(page.id, Number(id)), eq(page.workspaceId, Number(workspaceId))), ) .get(); @@ -98,8 +98,8 @@ export function registerPutPage(api: typeof pagesApi) { and( inArray(monitor.id, monitorIds), eq(monitor.workspaceId, Number(workspaceId)), - isNull(monitor.deletedAt) - ) + isNull(monitor.deletedAt), + ), ) .all(); @@ -132,8 +132,8 @@ export function registerPutPage(api: typeof pagesApi) { .where( and( inArray(monitorsToPages.monitorId, removedMonitors), - eq(monitorsToPages.pageId, newPage.id) - ) + eq(monitorsToPages.pageId, newPage.id), + ), ); } diff --git a/apps/server/src/v1/pages/schema.ts b/apps/server/src/v1/pages/schema.ts index fab4e9b983..ca800b0495 100644 --- a/apps/server/src/v1/pages/schema.ts +++ b/apps/server/src/v1/pages/schema.ts @@ -81,7 +81,7 @@ export const PageSchema = z.object({ { monitorId: 1, order: 0 }, { monitorId: 2, order: 1 }, ], - }) + }), ) .optional(), }); diff --git a/apps/server/src/v1/statusReportUpdates/get.ts b/apps/server/src/v1/statusReportUpdates/get.ts index 70c75f04c9..fdb4914039 100644 --- a/apps/server/src/v1/statusReportUpdates/get.ts +++ b/apps/server/src/v1/statusReportUpdates/get.ts @@ -3,10 +3,10 @@ import { createRoute } from "@hono/zod-openapi"; import { and, db, eq } from "@openstatus/db"; import { statusReport, statusReportUpdate } from "@openstatus/db/src/schema"; +import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { statusReportUpdatesApi } from "./index"; import { ParamsSchema, StatusReportUpdateSchema } from "./schema"; -import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; -import { HTTPException } from "hono/http-exception"; const getRoute = createRoute({ method: "get", @@ -30,7 +30,7 @@ const getRoute = createRoute({ }); export function registerGetStatusReportUpdate( - api: typeof statusReportUpdatesApi + api: typeof statusReportUpdatesApi, ) { return api.openapi(getRoute, async (c) => { const workspaceId = c.get("workspaceId"); @@ -43,8 +43,8 @@ export function registerGetStatusReportUpdate( statusReport, and( eq(statusReport.id, statusReportUpdate.statusReportId), - eq(statusReport.workspaceId, Number(workspaceId)) - ) + eq(statusReport.workspaceId, Number(workspaceId)), + ), ) .where(eq(statusReportUpdate.id, Number(id))) .get(); @@ -54,7 +54,7 @@ export function registerGetStatusReportUpdate( } const data = StatusReportUpdateSchema.parse( - _statusReportJoin.status_report_update + _statusReportJoin.status_report_update, ); return c.json(data); diff --git a/apps/server/src/v1/statusReportUpdates/index.ts b/apps/server/src/v1/statusReportUpdates/index.ts index d5bd671ae2..07efd7d579 100644 --- a/apps/server/src/v1/statusReportUpdates/index.ts +++ b/apps/server/src/v1/statusReportUpdates/index.ts @@ -1,9 +1,9 @@ import { OpenAPIHono } from "@hono/zod-openapi"; +import { handleZodError } from "../../libs/errors"; import type { Variables } from "../index"; import { registerGetStatusReportUpdate } from "./get"; import { registerPostStatusReportUpdate } from "./post"; -import { handleZodError } from "../../libs/errors"; export const statusReportUpdatesApi = new OpenAPIHono<{ Variables: Variables; diff --git a/apps/server/src/v1/statusReportUpdates/post.ts b/apps/server/src/v1/statusReportUpdates/post.ts index 7e5835c55f..6321429fec 100644 --- a/apps/server/src/v1/statusReportUpdates/post.ts +++ b/apps/server/src/v1/statusReportUpdates/post.ts @@ -10,10 +10,10 @@ import { } from "@openstatus/db/src/schema"; import { sendEmailHtml } from "@openstatus/emails"; +import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { statusReportUpdatesApi } from "./index"; import { StatusReportUpdateSchema } from "./schema"; -import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; -import { HTTPException } from "hono/http-exception"; const createStatusUpdate = createRoute({ method: "post", @@ -44,7 +44,7 @@ const createStatusUpdate = createRoute({ }); export function registerPostStatusReportUpdate( - api: typeof statusReportUpdatesApi + api: typeof statusReportUpdatesApi, ) { return api.openapi(createStatusUpdate, async (c) => { const workspaceId = c.get("workspaceId"); @@ -57,8 +57,8 @@ export function registerPostStatusReportUpdate( .where( and( eq(statusReport.id, input.statusReportId), - eq(statusReport.workspaceId, Number(workspaceId)) - ) + eq(statusReport.workspaceId, Number(workspaceId)), + ), ) .get(); @@ -95,8 +95,8 @@ export function registerPostStatusReportUpdate( .where( and( eq(pageSubscriber.pageId, currentPage.pageId), - isNotNull(pageSubscriber.acceptedAt) - ) + isNotNull(pageSubscriber.acceptedAt), + ), ) .all(); @@ -107,7 +107,7 @@ export function registerPostStatusReportUpdate( .get(); if (!pageInfo) continue; const subscribersEmails = subscribers.map( - (subscriber) => subscriber.email + (subscriber) => subscriber.email, ); // TODO: verify if we leak any email data here diff --git a/apps/server/src/v1/statusReports/delete.ts b/apps/server/src/v1/statusReports/delete.ts index e0ac5c656c..b4557639df 100644 --- a/apps/server/src/v1/statusReports/delete.ts +++ b/apps/server/src/v1/statusReports/delete.ts @@ -3,10 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi"; import { and, db, eq } from "@openstatus/db"; import { statusReport } from "@openstatus/db/src/schema"; +import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { statusReportsApi } from "./index"; import { ParamsSchema } from "./schema"; -import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; -import { HTTPException } from "hono/http-exception"; const deleteRoute = createRoute({ method: "delete", @@ -40,8 +40,8 @@ export function registerDeleteStatusReport(api: typeof statusReportsApi) { .where( and( eq(statusReport.id, Number(id)), - eq(statusReport.workspaceId, Number(workspaceId)) - ) + eq(statusReport.workspaceId, Number(workspaceId)), + ), ) .get(); diff --git a/apps/server/src/v1/statusReports/get.ts b/apps/server/src/v1/statusReports/get.ts index 28e870fdcf..72963debfc 100644 --- a/apps/server/src/v1/statusReports/get.ts +++ b/apps/server/src/v1/statusReports/get.ts @@ -3,10 +3,10 @@ import { createRoute } from "@hono/zod-openapi"; import { and, db, eq } from "@openstatus/db"; import { statusReport } from "@openstatus/db/src/schema"; +import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { statusReportsApi } from "./index"; import { ParamsSchema, StatusReportSchema } from "./schema"; -import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; -import { HTTPException } from "hono/http-exception"; const getRoute = createRoute({ method: "get", @@ -42,7 +42,7 @@ export function regsiterGetStatusReport(api: typeof statusReportsApi) { }, where: and( eq(statusReport.workspaceId, Number(workspaceId)), - eq(statusReport.id, Number(id)) + eq(statusReport.id, Number(id)), ), }); diff --git a/apps/server/src/v1/statusReports/get_all.ts b/apps/server/src/v1/statusReports/get_all.ts index 4dff1a52b9..23e408bda0 100644 --- a/apps/server/src/v1/statusReports/get_all.ts +++ b/apps/server/src/v1/statusReports/get_all.ts @@ -3,10 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi"; import { db, eq } from "@openstatus/db"; import { statusReport } from "@openstatus/db/src/schema"; +import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import type { statusReportsApi } from "./index"; import { StatusReportSchema } from "./schema"; -import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; -import { HTTPException } from "hono/http-exception"; const getAllRoute = createRoute({ method: "get", @@ -50,7 +50,7 @@ export function registerGetAllStatusReports(api: typeof statusReportsApi) { statusReportUpdateIds: r.statusReportUpdates.map((u) => u.id), pageIds: r.pagesToStatusReports.map((p) => p.pageId), monitorIds: r.monitorsToStatusReports.map((m) => m.monitorId), - })) + })), ); return c.json(data); diff --git a/apps/server/src/v1/statusReports/index.ts b/apps/server/src/v1/statusReports/index.ts index 00c6f1cf22..88d5202051 100644 --- a/apps/server/src/v1/statusReports/index.ts +++ b/apps/server/src/v1/statusReports/index.ts @@ -1,11 +1,11 @@ import { OpenAPIHono } from "@hono/zod-openapi"; +import { handleZodError } from "../../libs/errors"; import type { Variables } from "../index"; -import { registerGetAllStatusReports } from "./get_all"; import { registerDeleteStatusReport } from "./delete"; import { regsiterGetStatusReport } from "./get"; +import { registerGetAllStatusReports } from "./get_all"; import { registerPostStatusReport } from "./post"; -import { handleZodError } from "../../libs/errors"; import { registerStatusReportUpdateRoutes } from "./update/post"; export const statusReportsApi = new OpenAPIHono<{ Variables: Variables }>({ diff --git a/apps/server/src/v1/statusReports/post.ts b/apps/server/src/v1/statusReports/post.ts index 15d4e2204b..97b253da02 100644 --- a/apps/server/src/v1/statusReports/post.ts +++ b/apps/server/src/v1/statusReports/post.ts @@ -11,12 +11,12 @@ import { statusReportUpdate, } from "@openstatus/db/src/schema"; -import type { statusReportsApi } from "./index"; -import { StatusReportSchema } from "./schema"; -import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; +import { sendEmailHtml } from "@openstatus/emails"; import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses"; import { isoDate } from "../utils"; -import { sendEmailHtml } from "@openstatus/emails"; +import type { statusReportsApi } from "./index"; +import { StatusReportSchema } from "./schema"; const postRoute = createRoute({ method: "post", @@ -72,8 +72,8 @@ export function registerPostStatusReport(api: typeof statusReportsApi) { and( eq(monitor.workspaceId, Number(workspaceId)), inArray(monitor.id, monitorIds), - isNull(monitor.deletedAt) - ) + isNull(monitor.deletedAt), + ), ) .all(); @@ -89,8 +89,8 @@ export function registerPostStatusReport(api: typeof statusReportsApi) { .where( and( eq(page.workspaceId, Number(workspaceId)), - inArray(page.id, pageIds) - ) + inArray(page.id, pageIds), + ), ) .all(); @@ -127,7 +127,7 @@ export function registerPostStatusReport(api: typeof statusReportsApi) { pageId: id, statusReportId: _newStatusReport.id, }; - }) + }), ) .returning(); } @@ -141,7 +141,7 @@ export function registerPostStatusReport(api: typeof statusReportsApi) { monitorId: id, statusReportId: _newStatusReport.id, }; - }) + }), ) .returning(); } @@ -151,7 +151,7 @@ export function registerPostStatusReport(api: typeof statusReportsApi) { .select() .from(pagesToStatusReports) .where( - eq(pagesToStatusReports.statusReportId, Number(_newStatusReport.id)) + eq(pagesToStatusReports.statusReportId, Number(_newStatusReport.id)), ) .all(); for (const currentPage of allPages) { @@ -161,8 +161,8 @@ export function registerPostStatusReport(api: typeof statusReportsApi) { .where( and( eq(pageSubscriber.pageId, currentPage.pageId), - isNotNull(pageSubscriber.acceptedAt) - ) + isNotNull(pageSubscriber.acceptedAt), + ), ) .all(); const pageInfo = await db @@ -172,7 +172,7 @@ export function registerPostStatusReport(api: typeof statusReportsApi) { .get(); if (!pageInfo) continue; const subscribersEmails = subscribers.map( - (subscriber) => subscriber.email + (subscriber) => subscriber.email, ); await sendEmailHtml({ to: subscribersEmails, diff --git a/apps/server/src/v1/statusReports/update/post.ts b/apps/server/src/v1/statusReports/update/post.ts index 62a8ebe18f..c258e43b5c 100644 --- a/apps/server/src/v1/statusReports/update/post.ts +++ b/apps/server/src/v1/statusReports/update/post.ts @@ -1,8 +1,5 @@ import { createRoute } from "@hono/zod-openapi"; -import { ParamsSchema, StatusReportSchema } from "../schema"; -import { StatusReportUpdateSchema } from "../../statusReportUpdates/schema"; -import { openApiErrorResponses } from "../../../libs/errors/openapi-error-responses"; -import type { statusReportsApi } from "../index"; +import { and, db, eq, isNotNull } from "@openstatus/db"; import { page, pageSubscriber, @@ -10,9 +7,12 @@ import { statusReport, statusReportUpdate, } from "@openstatus/db/src/schema"; -import { and, db, eq, isNotNull } from "@openstatus/db"; import { sendEmailHtml } from "@openstatus/emails"; import { HTTPException } from "hono/http-exception"; +import { openApiErrorResponses } from "../../../libs/errors/openapi-error-responses"; +import { StatusReportUpdateSchema } from "../../statusReportUpdates/schema"; +import type { statusReportsApi } from "../index"; +import { ParamsSchema, StatusReportSchema } from "../schema"; const postRouteUpdate = createRoute({ method: "post", @@ -57,8 +57,8 @@ export function registerStatusReportUpdateRoutes(api: typeof statusReportsApi) { .where( and( eq(statusReport.id, Number(id)), - eq(statusReport.workspaceId, Number(workspaceId)) - ) + eq(statusReport.workspaceId, Number(workspaceId)), + ), ) .returning() .get(); @@ -90,8 +90,8 @@ export function registerStatusReportUpdateRoutes(api: typeof statusReportsApi) { .where( and( eq(pageSubscriber.pageId, currentPage.pageId), - isNotNull(pageSubscriber.acceptedAt) - ) + isNotNull(pageSubscriber.acceptedAt), + ), ) .all(); const pageInfo = await db @@ -101,7 +101,7 @@ export function registerStatusReportUpdateRoutes(api: typeof statusReportsApi) { .get(); if (!pageInfo) continue; const subscribersEmails = subscribers.map( - (subscriber) => subscriber.email + (subscriber) => subscriber.email, ); await sendEmailHtml({ to: subscribersEmails, diff --git a/apps/server/src/v1/utils.ts b/apps/server/src/v1/utils.ts index 7298c6f7c8..9d3191a21d 100644 --- a/apps/server/src/v1/utils.ts +++ b/apps/server/src/v1/utils.ts @@ -8,7 +8,7 @@ export const isoDate = z.preprocess((val) => { }, z.string()); export function isNumberArray( - monitors: number[] | T[] + monitors: number[] | T[], ): monitors is number[] { return ( Array.isArray(monitors) && diff --git a/apps/web/src/app/api/checker/cron/_cron.ts b/apps/web/src/app/api/checker/cron/_cron.ts index 06aeade05c..5952eb4636 100644 --- a/apps/web/src/app/api/checker/cron/_cron.ts +++ b/apps/web/src/app/api/checker/cron/_cron.ts @@ -45,7 +45,7 @@ export const cron = async ({ const parent = client.queuePath( env.GCP_PROJECT_ID, env.GCP_LOCATION, - periodicity + periodicity, ); const timestamp = Date.now(); @@ -54,7 +54,7 @@ export const cron = async ({ .select({ id: maintenance.id }) .from(maintenance) .where( - and(lte(maintenance.from, new Date()), gte(maintenance.to, new Date())) + and(lte(maintenance.from, new Date()), gte(maintenance.to, new Date())), ) .as("currentMaintenance"); @@ -63,7 +63,7 @@ export const cron = async ({ .from(maintenancesToMonitors) .innerJoin( currentMaintenance, - eq(maintenancesToMonitors.maintenanceId, currentMaintenance.id) + eq(maintenancesToMonitors.maintenanceId, currentMaintenance.id), ); const result = await db @@ -73,8 +73,8 @@ export const cron = async ({ and( eq(monitor.periodicity, periodicity), eq(monitor.active, true), - notInArray(monitor.id, currentMaintenanceMonitors) - ) + notInArray(monitor.id, currentMaintenanceMonitors), + ), ) .all(); @@ -127,7 +127,7 @@ export const cron = async ({ const failed = allRequests.filter((r) => r.status === "rejected").length; console.log( - `End cron for ${periodicity} with ${allResult.length} jobs with ${success} success and ${failed} failed` + `End cron for ${periodicity} with ${allResult.length} jobs with ${success} success and ${failed} failed`, ); }; // timestamp needs to be in ms diff --git a/apps/web/src/app/api/og/page/route.tsx b/apps/web/src/app/api/og/page/route.tsx index 94d1c790fa..10f5fce9a2 100644 --- a/apps/web/src/app/api/og/page/route.tsx +++ b/apps/web/src/app/api/og/page/route.tsx @@ -12,7 +12,7 @@ export const runtime = "edge"; export async function GET(req: Request) { const [interRegularData, interLightData, calSemiBoldData] = await Promise.all( - [interRegular, interLight, calSemiBold] + [interRegular, interLight, calSemiBold], ); const { searchParams } = new URL(req.url); @@ -34,11 +34,9 @@ export async function GET(req: Request) { }); return new ImageResponse( - ( - - - - ), + + + , { ...SIZE, fonts: [ @@ -61,6 +59,6 @@ export async function GET(req: Request) { weight: 600, }, ], - } + }, ); } diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx index 87834e44e1..0bf4bc7195 100644 --- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx +++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx @@ -32,7 +32,7 @@ const searchParamsSchema = z.object({ if (v === "true") return true; if (v === "false") return false; return undefined; - }) + }), ) .optional(), }); @@ -74,34 +74,34 @@ export default async function MonitorPage({ { monitorId: String(monitor.id), }, - { cache: "no-store", revalidate: 0 } + { cache: "no-store", revalidate: 0 }, ); const data = await tb.endpointStatusPeriod("7d")( { monitorId: String(monitor.id), }, - { cache: "no-store", revalidate: 0 } + { cache: "no-store", revalidate: 0 }, ); const [current] = metrics?.sort((a, b) => - (a.lastTimestamp || 0) - (b.lastTimestamp || 0) < 0 ? 1 : -1 + (a.lastTimestamp || 0) - (b.lastTimestamp || 0) < 0 ? 1 : -1, ) || [undefined]; const incidents = _incidents.filter( - (incident) => incident.monitorId === monitor.id + (incident) => incident.monitorId === monitor.id, ); const tags = monitor.monitorTagsToMonitors.map( - ({ monitorTag }) => monitorTag + ({ monitorTag }) => monitorTag, ); const maintenances = _maintenances.filter((maintenance) => - maintenance.monitors.includes(monitor.id) + maintenance.monitors.includes(monitor.id), ); return { monitor, metrics: current, data, incidents, maintenances, tags }; - }) + }), ); return ( diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx index 3f3cea950b..87af8d3127 100644 --- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx +++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx @@ -45,7 +45,7 @@ export default async function Layout({ monitorTag + ({ monitorTag }) => monitorTag, )} /> diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/_components/rum-card.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/_components/rum-card.tsx index 71afb0d5a7..1fa4b28085 100644 --- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/_components/rum-card.tsx +++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/_components/rum-card.tsx @@ -1,6 +1,6 @@ -import { Card } from "@tremor/react"; import { getColorByType, webVitalsConfig } from "@openstatus/rum"; import type { WebVitalEvents, WebVitalsValues } from "@openstatus/rum"; +import { Card } from "@tremor/react"; import { CategoryBar } from "./category-bar"; export function prepareWebVitalValues(values: WebVitalsValues) { diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/overview/_components/session-table.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/overview/_components/session-table.tsx index dc4e1c3f27..97f400dea1 100644 --- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/overview/_components/session-table.tsx +++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/overview/_components/session-table.tsx @@ -1,7 +1,7 @@ import { api } from "@/trpc/server"; -import { DataTableWrapper } from "./data-table-wrapper"; import { useSearchParams } from "next/navigation"; import { use } from "react"; +import { DataTableWrapper } from "./data-table-wrapper"; const SessionTable = async ({ dsn, path }: { dsn: string; path: string }) => { const data = await api.tinybird.sessionRumMetricsForPath.query({ diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/overview/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/overview/page.tsx index 599cf2bf41..3d5acaf342 100644 --- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/overview/page.tsx +++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/overview/page.tsx @@ -1,9 +1,9 @@ import * as React from "react"; -import { PathCard } from "./_components/path-card"; import { api } from "@/trpc/server"; -import { SessionTable } from "./_components/session-table"; import { z } from "zod"; +import { PathCard } from "./_components/path-card"; +import { SessionTable } from "./_components/session-table"; const searchParamsSchema = z.object({ path: z.string(), diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/page.tsx index 28d796898f..4cc9be252f 100644 --- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/page.tsx +++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/rum/page.tsx @@ -1,12 +1,12 @@ import * as React from "react"; import { EmptyState } from "@/components/dashboard/empty-state"; +import { auth } from "@/lib/auth"; import { api } from "@/trpc/server"; -import { RouteTable } from "./_components/route-table"; -import { RUMMetricCards } from "./_components/rum-metric-card"; import { Redis } from "@upstash/redis"; -import { auth } from "@/lib/auth"; import { RequestButton } from "./_components/request-button/request-button"; +import { RouteTable } from "./_components/route-table"; +import { RUMMetricCards } from "./_components/rum-metric-card"; export const dynamic = "force-dynamic"; @@ -20,7 +20,7 @@ export default async function RUMPage() { const accessRequested = await redis.sismember( "rum_access_requested", - session.user.email + session.user.email, ); if (applications.length === 0) { diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/_components/info-banner.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/_components/info-banner.tsx index 3028a98be3..4e23e82da1 100644 --- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/_components/info-banner.tsx +++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/_components/info-banner.tsx @@ -1,8 +1,8 @@ "use client"; +import { Info } from "lucide-react"; import Link from "next/link"; import { useParams } from "next/navigation"; -import { Info } from "lucide-react"; import { Alert, AlertDescription, AlertTitle } from "@openstatus/ui"; @@ -16,7 +16,7 @@ export function InfoBanner() { To inform your team about the workspace name, please set it in the{" "} general {" "} diff --git a/apps/web/src/app/app/invite/_components/link-cards.tsx b/apps/web/src/app/app/invite/_components/link-cards.tsx index 207c462011..e89b63b83b 100644 --- a/apps/web/src/app/app/invite/_components/link-cards.tsx +++ b/apps/web/src/app/app/invite/_components/link-cards.tsx @@ -1,5 +1,5 @@ -import Link from "next/link"; import { ArrowRight, ArrowUpRight } from "lucide-react"; +import Link from "next/link"; import { Card, CardDescription, CardHeader, CardTitle } from "@openstatus/ui"; @@ -46,9 +46,9 @@ export function LinkCards({ slug }: { slug: string }) {
{link.description} {isExternal ? ( - + ) : ( - + )}
diff --git a/apps/web/src/app/app/invite/page.tsx b/apps/web/src/app/app/invite/page.tsx index abb34274cb..144333b53d 100644 --- a/apps/web/src/app/app/invite/page.tsx +++ b/apps/web/src/app/app/invite/page.tsx @@ -30,7 +30,7 @@ export default async function InvitePage({ if (!data) { return (
-

Invitation

+

Invitation

Something went wrong @@ -45,7 +45,7 @@ export default async function InvitePage({ return (
-

Invitation

+

Invitation

Ready to go diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx index 3f1dab57ec..bb92bc8a1b 100644 --- a/apps/web/src/app/layout.tsx +++ b/apps/web/src/app/layout.tsx @@ -4,8 +4,8 @@ import type { Metadata } from "next"; import { Inter } from "next/font/google"; import LocalFont from "next/font/local"; -import { OpenStatusProvider } from "@openstatus/next-monitoring"; import { Toaster } from "@/components/ui/sonner"; +import { OpenStatusProvider } from "@openstatus/next-monitoring"; import { defaultMetadata, diff --git a/apps/web/src/app/status-page/[domain]/badge/route.tsx b/apps/web/src/app/status-page/[domain]/badge/route.tsx index c9e389c796..985b9a65bb 100644 --- a/apps/web/src/app/status-page/[domain]/badge/route.tsx +++ b/apps/web/src/app/status-page/[domain]/badge/route.tsx @@ -45,7 +45,7 @@ const SIZE: Record = { }; export async function GET( req: NextRequest, - { params }: { params: { domain: string } } + { params }: { params: { domain: string } }, ) { const { status } = await getStatus(params.domain); const theme = req.nextUrl.searchParams.get("theme"); @@ -61,20 +61,18 @@ export async function GET( const dark = "border-gray-800 text-gray-300 bg-gray-900"; return new ImageResponse( - ( -
- {label} -
-
- ), - { ...s } + style={{ ...s }} + > + {label} +
+
, + { ...s }, ); } diff --git a/apps/web/src/app/status-page/[domain]/incidents/[id]/page.tsx b/apps/web/src/app/status-page/[domain]/incidents/[id]/page.tsx index 8737d16e9d..9916358c48 100644 --- a/apps/web/src/app/status-page/[domain]/incidents/[id]/page.tsx +++ b/apps/web/src/app/status-page/[domain]/incidents/[id]/page.tsx @@ -21,7 +21,7 @@ export default async function IncidentPage({ if (!report) return notFound(); const affectedMonitors = report.monitorsToStatusReports.map( - ({ monitor }) => monitor + ({ monitor }) => monitor, ); return ( diff --git a/apps/web/src/app/status-page/[domain]/page.tsx b/apps/web/src/app/status-page/[domain]/page.tsx index 74c5152dec..15406ab757 100644 --- a/apps/web/src/app/status-page/[domain]/page.tsx +++ b/apps/web/src/app/status-page/[domain]/page.tsx @@ -4,11 +4,11 @@ import { notFound } from "next/navigation"; import { Separator } from "@openstatus/ui"; import { Header } from "@/components/dashboard/header"; +import { MaintenanceBanner } from "@/components/status-page/maintenance-banner"; import { MonitorList } from "@/components/status-page/monitor-list"; import { StatusCheck } from "@/components/status-page/status-check"; import { StatusReportList } from "@/components/status-page/status-report-list"; import { api } from "@/trpc/server"; -import { MaintenanceBanner } from "@/components/status-page/maintenance-banner"; type Props = { params: { domain: string }; @@ -25,7 +25,7 @@ export default async function Page({ params }: Props) { const currentMaintenances = page.maintenances.filter( (maintenance) => maintenance.to.getTime() > Date.now() && - maintenance.from.getTime() < Date.now() + maintenance.from.getTime() < Date.now(), ); return ( diff --git a/apps/web/src/components/data-table/data-table-faceted-filter.tsx b/apps/web/src/components/data-table/data-table-faceted-filter.tsx index 2a59d0b307..8177d287ce 100644 --- a/apps/web/src/components/data-table/data-table-faceted-filter.tsx +++ b/apps/web/src/components/data-table/data-table-faceted-filter.tsx @@ -41,11 +41,11 @@ export function DataTableFacetedFilter({ const facets = column?.getFacetedUniqueValues(); const selectedValues = new Set( - column?.getFilterValue() as (string | number | boolean)[] + column?.getFilterValue() as (string | number | boolean)[], ); const updatePageSearchParams = ( - values: Record + values: Record, ) => { const newSearchParams = updateSearchParams(values); router.replace(`?${newSearchParams}`, { scroll: false }); @@ -111,7 +111,7 @@ export function DataTableFacetedFilter({ } const filterValues = Array.from(selectedValues); column?.setFilterValue( - filterValues.length ? filterValues : undefined + filterValues.length ? filterValues : undefined, ); // update search params @@ -128,7 +128,7 @@ export function DataTableFacetedFilter({ "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary", isSelected ? "bg-primary text-primary-foreground" - : "opacity-50 [&_svg]:invisible" + : "opacity-50 [&_svg]:invisible", )} > diff --git a/apps/web/src/components/data-table/maintenance/columns.tsx b/apps/web/src/components/data-table/maintenance/columns.tsx index d5f12cffdb..c4fca5db49 100644 --- a/apps/web/src/components/data-table/maintenance/columns.tsx +++ b/apps/web/src/components/data-table/maintenance/columns.tsx @@ -4,9 +4,9 @@ import type { ColumnDef } from "@tanstack/react-table"; import type { Maintenance } from "@openstatus/db/src/schema"; -import { DataTableRowActions } from "./data-table-row-actions"; import { formatDateTime } from "@/lib/utils"; import { format } from "date-fns"; +import { DataTableRowActions } from "./data-table-row-actions"; export const columns: ColumnDef[] = [ { diff --git a/apps/web/src/components/data-table/monitor/columns.tsx b/apps/web/src/components/data-table/monitor/columns.tsx index 56dcc3d59d..f52ee38cd5 100644 --- a/apps/web/src/components/data-table/monitor/columns.tsx +++ b/apps/web/src/components/data-table/monitor/columns.tsx @@ -84,7 +84,7 @@ export const columns: ColumnDef<{ // REMINDER: if one value is found, return true // we could consider restricting it to all the values have to be found return value.some((item) => - row.original.tags?.some((tag) => tag.name === item) + row.original.tags?.some((tag) => tag.name === item), ); }, }, diff --git a/apps/web/src/components/data-table/rum/data-table.tsx b/apps/web/src/components/data-table/rum/data-table.tsx index c8cdc7e34f..d7e57ef593 100644 --- a/apps/web/src/components/data-table/rum/data-table.tsx +++ b/apps/web/src/components/data-table/rum/data-table.tsx @@ -45,7 +45,7 @@ export function DataTable({ ? null : flexRender( header.column.columnDef.header, - header.getContext() + header.getContext(), )} ); diff --git a/apps/web/src/components/data-table/session/data-table.tsx b/apps/web/src/components/data-table/session/data-table.tsx index c8cdc7e34f..d7e57ef593 100644 --- a/apps/web/src/components/data-table/session/data-table.tsx +++ b/apps/web/src/components/data-table/session/data-table.tsx @@ -45,7 +45,7 @@ export function DataTable({ ? null : flexRender( header.column.columnDef.header, - header.getContext() + header.getContext(), )} ); diff --git a/apps/web/src/components/data-table/status-page/columns.tsx b/apps/web/src/components/data-table/status-page/columns.tsx index b093121b2d..744b82fcfc 100644 --- a/apps/web/src/components/data-table/status-page/columns.tsx +++ b/apps/web/src/components/data-table/status-page/columns.tsx @@ -14,8 +14,8 @@ import { TooltipTrigger, } from "@openstatus/ui"; -import { DataTableRowActions } from "./data-table-row-actions"; import { Check } from "lucide-react"; +import { DataTableRowActions } from "./data-table-row-actions"; export const columns: ColumnDef< Page & { diff --git a/apps/web/src/components/dev-mode-container.tsx b/apps/web/src/components/dev-mode-container.tsx index 2dea801947..906caae656 100644 --- a/apps/web/src/components/dev-mode-container.tsx +++ b/apps/web/src/components/dev-mode-container.tsx @@ -11,7 +11,7 @@ export default function DevModeContainer({

diff --git a/apps/web/src/components/forms/maintenance/general.tsx b/apps/web/src/components/forms/maintenance/general.tsx index f25f0373c6..cc7e726701 100644 --- a/apps/web/src/components/forms/maintenance/general.tsx +++ b/apps/web/src/components/forms/maintenance/general.tsx @@ -16,8 +16,8 @@ import { Textarea, } from "@openstatus/ui"; -import { SectionHeader } from "../shared/section-header"; import { format } from "date-fns"; +import { SectionHeader } from "../shared/section-header"; interface Props { form: UseFormReturn; diff --git a/apps/web/src/components/forms/maintenance/section-connect.tsx b/apps/web/src/components/forms/maintenance/section-connect.tsx index 69a104ee47..05c88b32fb 100644 --- a/apps/web/src/components/forms/maintenance/section-connect.tsx +++ b/apps/web/src/components/forms/maintenance/section-connect.tsx @@ -63,8 +63,8 @@ export function SectionConnect({ form, monitors }: Props) { ]) : field.onChange( field.value?.filter( - (value) => value !== item.id - ) + (value) => value !== item.id, + ), ); }} > diff --git a/apps/web/src/components/forms/monitor/section-notifications.tsx b/apps/web/src/components/forms/monitor/section-notifications.tsx index f262bd2165..3dd7398954 100644 --- a/apps/web/src/components/forms/monitor/section-notifications.tsx +++ b/apps/web/src/components/forms/monitor/section-notifications.tsx @@ -86,8 +86,8 @@ export function SectionNotifications({ form, plan, notifications }: Props) { ]) : field.onChange( field.value?.filter( - (value) => value !== item.id - ) + (value) => value !== item.id, + ), ); }} > diff --git a/apps/web/src/components/forms/monitor/section-scheduling.tsx b/apps/web/src/components/forms/monitor/section-scheduling.tsx index 564eb43fdc..52711e2162 100644 --- a/apps/web/src/components/forms/monitor/section-scheduling.tsx +++ b/apps/web/src/components/forms/monitor/section-scheduling.tsx @@ -120,8 +120,8 @@ export function SectionScheduling({ form, plan }: Props) { ]) : field.onChange( field.value?.filter( - (value) => value !== item - ) + (value) => value !== item, + ), ); }} > diff --git a/apps/web/src/components/forms/monitor/section-status-page.tsx b/apps/web/src/components/forms/monitor/section-status-page.tsx index 26c4d49413..de319ef05b 100644 --- a/apps/web/src/components/forms/monitor/section-status-page.tsx +++ b/apps/web/src/components/forms/monitor/section-status-page.tsx @@ -89,8 +89,8 @@ export function SectionStatusPage({ form, pages }: Props) { ]) : field.onChange( field.value?.filter( - (value) => value !== item.id - ) + (value) => value !== item.id, + ), ); }} > diff --git a/apps/web/src/components/forms/notification/form.tsx b/apps/web/src/components/forms/notification/form.tsx index c06987cf6a..fd0dd293b5 100644 --- a/apps/web/src/components/forms/notification/form.tsx +++ b/apps/web/src/components/forms/notification/form.tsx @@ -15,6 +15,9 @@ import { Button, Form } from "@openstatus/ui"; import { LoadingAnimation } from "@/components/loading-animation"; import { toast, toastAction } from "@/lib/toast"; import { api } from "@/trpc/client"; +import { SchemaError } from "@openstatus/error"; +import { TRPCClientError } from "@trpc/client"; +import { ZodError, type ZodIssue } from "zod"; import { SaveButton } from "../shared/save-button"; import { getDefaultProviderData, @@ -22,9 +25,6 @@ import { setProviderData, } from "./config"; import { General } from "./general"; -import { TRPCClientError } from "@trpc/client"; -import { ZodError, type ZodIssue } from "zod"; -import { SchemaError } from "@openstatus/error"; interface Props { defaultValues?: InsertNotification; diff --git a/apps/web/src/components/forms/shared/checkbox-label.tsx b/apps/web/src/components/forms/shared/checkbox-label.tsx index f582e37ddf..8611336536 100644 --- a/apps/web/src/components/forms/shared/checkbox-label.tsx +++ b/apps/web/src/components/forms/shared/checkbox-label.tsx @@ -34,7 +34,7 @@ export function CheckboxLabel({ htmlFor={`${name}-${id}`} className={cn( "flex h-full items-center gap-1 rounded-md border border-border bg-popover p-4 pr-10 [&:has([data-state=checked])]:border-primary peer-data-[state=checked]:border-primary hover:bg-accent hover:text-accent-foreground", - className + className, )} > {children} diff --git a/apps/web/src/components/layout/app-sidebar.tsx b/apps/web/src/components/layout/app-sidebar.tsx index e83568e627..866503df91 100644 --- a/apps/web/src/components/layout/app-sidebar.tsx +++ b/apps/web/src/components/layout/app-sidebar.tsx @@ -8,7 +8,7 @@ import { AppLink } from "./app-link"; function replacePlaceholders( template: string, - values: { [key: string]: string } + values: { [key: string]: string }, ): string { return template.replace(/\[([^\]]+)\]/g, (_, key) => { return values[key] || `[${key}]`; diff --git a/apps/web/src/components/marketing/alert/timeline.tsx b/apps/web/src/components/marketing/alert/timeline.tsx index 3014978119..9873876188 100644 --- a/apps/web/src/components/marketing/alert/timeline.tsx +++ b/apps/web/src/components/marketing/alert/timeline.tsx @@ -29,7 +29,7 @@ export function TimelineEvent({

diff --git a/apps/web/src/components/marketing/hero.tsx b/apps/web/src/components/marketing/hero.tsx index 96afddfc5f..5606d540ad 100644 --- a/apps/web/src/components/marketing/hero.tsx +++ b/apps/web/src/components/marketing/hero.tsx @@ -27,7 +27,7 @@ export function Hero() {

A better way to monitor your services. diff --git a/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx b/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx index 5c7b053a78..dd664ccac1 100644 --- a/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx +++ b/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx @@ -4,9 +4,9 @@ import { useSearchParams } from "next/navigation"; import type { WorkspacePlan } from "@openstatus/plans"; +import { Suspense } from "react"; import { PricingPlanRadio } from "./pricing-plan-radio"; import { PricingTable } from "./pricing-table"; -import { Suspense } from "react"; export function PricingWrapper() { const searchParams = useSearchParams(); diff --git a/apps/web/src/components/monitor-dashboard/metrics.tsx b/apps/web/src/components/monitor-dashboard/metrics.tsx index 3f224b6443..24157d7bdf 100644 --- a/apps/web/src/components/monitor-dashboard/metrics.tsx +++ b/apps/web/src/components/monitor-dashboard/metrics.tsx @@ -27,7 +27,7 @@ export function Metrics({ if (!metrics || metrics.length === 0) return null; const [current, last] = metrics.sort((a, b) => - (a.lastTimestamp || 0) - (b.lastTimestamp || 0) < 0 ? 1 : -1 + (a.lastTimestamp || 0) - (b.lastTimestamp || 0) < 0 ? 1 : -1, ); const isEmpty = current.count === 0; diff --git a/apps/web/src/components/status-page/maintenance-banner.tsx b/apps/web/src/components/status-page/maintenance-banner.tsx index db71888e26..68a31baa8b 100644 --- a/apps/web/src/components/status-page/maintenance-banner.tsx +++ b/apps/web/src/components/status-page/maintenance-banner.tsx @@ -1,4 +1,4 @@ -import { isSameDay, format } from "date-fns"; +import { format, isSameDay } from "date-fns"; import { Hammer } from "lucide-react"; import type { Maintenance } from "@openstatus/db/src/schema"; diff --git a/apps/web/src/components/status-page/monitor-list.tsx b/apps/web/src/components/status-page/monitor-list.tsx index 24d2530303..a7b428fd3b 100644 --- a/apps/web/src/components/status-page/monitor-list.tsx +++ b/apps/web/src/components/status-page/monitor-list.tsx @@ -26,14 +26,14 @@ export const MonitorList = ({ {monitors.map((monitor, _index) => { const monitorStatusReport = statusReports.filter((statusReport) => statusReport.monitorsToStatusReports.some( - (i) => i.monitor.id === monitor.id - ) + (i) => i.monitor.id === monitor.id, + ), ); const monitorIncidents = incidents.filter( - (incident) => incident.monitorId === monitor.id + (incident) => incident.monitorId === monitor.id, ); const monitorMaintenances = maintenances.filter((maintenance) => - maintenance.monitors?.includes(monitor.id) + maintenance.monitors?.includes(monitor.id), ); return ( { if (filter.open && report.status !== "resolved") return true; return report.statusReportUpdates.some( - (update) => update.date.getTime() > filter?.date?.getTime() + (update) => update.date.getTime() > filter?.date?.getTime(), ); }); } diff --git a/apps/web/src/components/status-page/status-report.tsx b/apps/web/src/components/status-page/status-report.tsx index 78719f6f31..d44831bf91 100644 --- a/apps/web/src/components/status-page/status-report.tsx +++ b/apps/web/src/components/status-page/status-report.tsx @@ -13,9 +13,9 @@ import type { import { Badge, Button } from "@openstatus/ui"; import { setPrefixUrl } from "@/app/status-page/[domain]/utils"; +import { cn } from "@/lib/utils"; import { StatusBadge } from "../status-update/status-badge"; import { ProcessMessage } from "./process-message"; -import { cn } from "@/lib/utils"; function StatusReport({ report, diff --git a/apps/web/src/components/support/bubble.tsx b/apps/web/src/components/support/bubble.tsx index 2b710e6b1d..7003a17e7f 100644 --- a/apps/web/src/components/support/bubble.tsx +++ b/apps/web/src/components/support/bubble.tsx @@ -1,7 +1,7 @@ "use client"; -import { useState } from "react"; import { MessageCircle } from "lucide-react"; +import { useState } from "react"; import { Button, @@ -10,8 +10,8 @@ import { PopoverTrigger, } from "@openstatus/ui"; -import { ContactForm } from "./contact-form"; import { useSession } from "next-auth/react"; +import { ContactForm } from "./contact-form"; export function Bubble() { const [open, setOpen] = useState(false); diff --git a/apps/web/src/components/support/contact-form.tsx b/apps/web/src/components/support/contact-form.tsx index 280f01498e..9585384e5c 100644 --- a/apps/web/src/components/support/contact-form.tsx +++ b/apps/web/src/components/support/contact-form.tsx @@ -1,7 +1,7 @@ "use client"; -import { useTransition } from "react"; import { zodResolver } from "@hookform/resolvers/zod"; +import { useTransition } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; @@ -23,9 +23,9 @@ import { Textarea, } from "@openstatus/ui"; +import { toast } from "@/lib/toast"; import { LoadingAnimation } from "../loading-animation"; import { handlePlainSupport } from "./action"; -import { toast } from "@/lib/toast"; export const types = [ { @@ -84,7 +84,7 @@ export function ContactForm({ } else { handleSubmit?.(); toast.success( - "Your message has been sent! We will get back to you soon." + "Your message has been sent! We will get back to you soon.", ); } }); diff --git a/apps/web/src/components/tracker/tracker.tsx b/apps/web/src/components/tracker/tracker.tsx index dfa6bea5bd..151743116b 100644 --- a/apps/web/src/components/tracker/tracker.tsx +++ b/apps/web/src/components/tracker/tracker.tsx @@ -150,7 +150,7 @@ export const Bar = ({
@@ -245,7 +245,7 @@ export function DowntimeText({ Down for{" "} {formatDuration( { minutes, hours, days }, - { format: ["days", "hours", "minutes", "seconds"], zero: false } + { format: ["days", "hours", "minutes", "seconds"], zero: false }, )}

); diff --git a/apps/web/src/config/pages.ts b/apps/web/src/config/pages.ts index aea5518d09..367968ba76 100644 --- a/apps/web/src/config/pages.ts +++ b/apps/web/src/config/pages.ts @@ -247,7 +247,7 @@ export const marketingPagesConfig = [ export function getPageBySegment( segment: string | string[], - currentPage: readonly Page[] = pagesConfig + currentPage: readonly Page[] = pagesConfig, ): Page | undefined { if (typeof segment === "string") { const page = currentPage.find((page) => page.segment === segment); diff --git a/apps/web/src/lib/auth/index.ts b/apps/web/src/lib/auth/index.ts index 8003889805..3dba7b950f 100644 --- a/apps/web/src/lib/auth/index.ts +++ b/apps/web/src/lib/auth/index.ts @@ -6,9 +6,9 @@ import { db, eq } from "@openstatus/db"; import { user } from "@openstatus/db/src/schema"; import { WelcomeEmail, sendEmail } from "@openstatus/emails"; +import { identifyUser } from "@/providers/posthog"; import { adapter } from "./adapter"; import { GitHubProvider, GoogleProvider, ResendProvider } from "./providers"; -import { identifyUser } from "@/providers/posthog"; export type { DefaultSession }; diff --git a/apps/web/src/lib/timezone.ts b/apps/web/src/lib/timezone.ts index 8f0cdbaafb..fa50750d18 100644 --- a/apps/web/src/lib/timezone.ts +++ b/apps/web/src/lib/timezone.ts @@ -94,7 +94,7 @@ export function getClosestTimezone(defaultTimezone?: string) { } return prev; }, - { timezone: "UTC", minDifference: Number.POSITIVE_INFINITY } + { timezone: "UTC", minDifference: Number.POSITIVE_INFINITY }, ); return closestTimezone.timezone as keyof typeof timeDifferences; diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts index 7e4efc9130..23a2860a2b 100644 --- a/apps/web/src/lib/utils.ts +++ b/apps/web/src/lib/utils.ts @@ -40,7 +40,7 @@ export function formatDuration(ms: number) { } export function notEmpty( - value: TValue | null | undefined + value: TValue | null | undefined, ): value is TValue { return value !== null && value !== undefined; } @@ -69,7 +69,7 @@ export function manipulateDate( date?: { from: Date | undefined; to?: Date | undefined; - } | null + } | null, ) { const isToDateMidnight = String(date?.to?.getTime()).endsWith("00000"); diff --git a/apps/web/src/providers/posthog.tsx b/apps/web/src/providers/posthog.tsx index f8a8446471..20855050f1 100644 --- a/apps/web/src/providers/posthog.tsx +++ b/apps/web/src/providers/posthog.tsx @@ -1,11 +1,11 @@ "use client"; -import { useEffect } from "react"; -import { usePathname, useSearchParams } from "next/navigation"; import type { User } from "next-auth"; +import { usePathname, useSearchParams } from "next/navigation"; import type { CaptureOptions, Properties } from "posthog-js"; import posthog from "posthog-js"; import { PostHogProvider } from "posthog-js/react"; +import { useEffect } from "react"; import { env } from "@/env"; diff --git a/packages/api/src/router/invitation.ts b/packages/api/src/router/invitation.ts index 340dd51b21..2011417389 100644 --- a/packages/api/src/router/invitation.ts +++ b/packages/api/src/router/invitation.ts @@ -34,7 +34,7 @@ export const invitationRouter = createTRPCRouter({ where: and( eq(invitation.workspaceId, opts.ctx.workspace.id), gte(invitation.expiresAt, new Date()), - isNull(invitation.acceptedAt) + isNull(invitation.acceptedAt), ), }) ).length; @@ -60,7 +60,7 @@ export const invitationRouter = createTRPCRouter({ if (process.env.NODE_ENV === "development") { console.log( - `>>>> Invitation token: http://localhost:3000/app/invite?token=${token} <<<< ` + `>>>> Invitation token: http://localhost:3000/app/invite?token=${token} <<<< `, ); } else { await fetch("https://api.resend.com/emails", { @@ -104,8 +104,8 @@ export const invitationRouter = createTRPCRouter({ .where( and( eq(invitation.id, opts.input.id), - eq(invitation.workspaceId, opts.ctx.workspace.id) - ) + eq(invitation.workspaceId, opts.ctx.workspace.id), + ), ) .run(); }), @@ -115,7 +115,7 @@ export const invitationRouter = createTRPCRouter({ where: and( eq(invitation.workspaceId, opts.ctx.workspace.id), gte(invitation.expiresAt, new Date()), - isNull(invitation.acceptedAt) + isNull(invitation.acceptedAt), ), }); return _invitations; @@ -144,13 +144,13 @@ export const invitationRouter = createTRPCRouter({ z.object({ message: z.string(), data: selectWorkspaceSchema.optional(), - }) + }), ) .mutation(async (opts) => { const _invitation = await opts.ctx.db.query.invitation.findFirst({ where: and( eq(invitation.token, opts.input.token), - isNull(invitation.acceptedAt) + isNull(invitation.acceptedAt), ), with: { workspace: true, diff --git a/packages/api/src/router/maintenance.ts b/packages/api/src/router/maintenance.ts index d170dab537..b99f6f256d 100644 --- a/packages/api/src/router/maintenance.ts +++ b/packages/api/src/router/maintenance.ts @@ -8,8 +8,8 @@ import { selectMaintenanceSchema, } from "@openstatus/db/src/schema"; -import { createTRPCRouter, protectedProcedure } from "../trpc"; import { TRPCError } from "@trpc/server"; +import { createTRPCRouter, protectedProcedure } from "../trpc"; export const maintenanceRouter = createTRPCRouter({ create: protectedProcedure @@ -28,7 +28,7 @@ export const maintenanceRouter = createTRPCRouter({ opts.input.monitors.map((monitorId) => ({ maintenanceId: _maintenance.id, monitorId, - })) + })), ) .returning() .get(); @@ -45,8 +45,8 @@ export const maintenanceRouter = createTRPCRouter({ .where( and( eq(maintenance.id, opts.input.id), - eq(maintenance.workspaceId, opts.ctx.workspace.id) - ) + eq(maintenance.workspaceId, opts.ctx.workspace.id), + ), ) .get(); @@ -71,7 +71,7 @@ export const maintenanceRouter = createTRPCRouter({ const _maintenances = await opts.ctx.db.query.maintenance.findMany({ where: and( eq(maintenance.workspaceId, opts.ctx.workspace.id), - gte(maintenance.from, new Date(Date.now() - 7 * 24 * 60 * 60 * 1000)) + gte(maintenance.from, new Date(Date.now() - 7 * 24 * 60 * 60 * 1000)), ), with: { maintenancesToMonitors: true }, }); @@ -89,8 +89,8 @@ export const maintenanceRouter = createTRPCRouter({ .where( and( eq(maintenance.pageId, opts.input.id), - eq(maintenance.workspaceId, opts.ctx.workspace.id) - ) + eq(maintenance.workspaceId, opts.ctx.workspace.id), + ), ) .all(); // TODO: @@ -104,8 +104,8 @@ export const maintenanceRouter = createTRPCRouter({ and( eq(maintenance.workspaceId, opts.ctx.workspace.id), gte(maintenance.to, new Date()), - lte(maintenance.from, new Date()) - ) + lte(maintenance.from, new Date()), + ), ) .all(); return _maintenances; @@ -123,8 +123,8 @@ export const maintenanceRouter = createTRPCRouter({ .where( and( eq(maintenance.id, opts.input.id), - eq(maintenance.workspaceId, opts.ctx.workspace.id) - ) + eq(maintenance.workspaceId, opts.ctx.workspace.id), + ), ) .returning() .get(); @@ -136,11 +136,11 @@ export const maintenanceRouter = createTRPCRouter({ .all(); const _monitorsIds = _maintenancesToMonitors.map( - ({ monitorId }) => monitorId + ({ monitorId }) => monitorId, ); const added = opts.input.monitors?.filter( - (monitor) => !_monitorsIds.includes(monitor) + (monitor) => !_monitorsIds.includes(monitor), ); if (added?.length) { @@ -150,14 +150,14 @@ export const maintenanceRouter = createTRPCRouter({ added.map((monitorId) => ({ maintenanceId: _maintenance.id, monitorId, - })) + })), ) .returning() .get(); } const removed = _monitorsIds.filter( - (monitor) => !opts.input.monitors?.includes(monitor) + (monitor) => !opts.input.monitors?.includes(monitor), ); if (removed?.length) { @@ -166,8 +166,8 @@ export const maintenanceRouter = createTRPCRouter({ .where( and( eq(maintenancesToMonitors.maintenanceId, _maintenance.id), - inArray(maintenancesToMonitors.monitorId, removed) - ) + inArray(maintenancesToMonitors.monitorId, removed), + ), ) .run(); } @@ -182,8 +182,8 @@ export const maintenanceRouter = createTRPCRouter({ .where( and( eq(maintenance.id, opts.input.id), - eq(maintenance.workspaceId, opts.ctx.workspace.id) - ) + eq(maintenance.workspaceId, opts.ctx.workspace.id), + ), ) .returning(); }), diff --git a/packages/api/src/router/monitor.ts b/packages/api/src/router/monitor.ts index 03d4e0c737..4f59a6940b 100644 --- a/packages/api/src/router/monitor.ts +++ b/packages/api/src/router/monitor.ts @@ -43,7 +43,7 @@ export const monitorRouter = createTRPCRouter({ await opts.ctx.db.query.monitor.findMany({ where: and( eq(monitor.workspaceId, opts.ctx.workspace.id), - isNull(monitor.deletedAt) + isNull(monitor.deletedAt), ), }) ).length; @@ -106,7 +106,7 @@ export const monitorRouter = createTRPCRouter({ const allNotifications = await opts.ctx.db.query.notification.findMany({ where: and( eq(notification.workspaceId, opts.ctx.workspace.id), - inArray(notification.id, notifications) + inArray(notification.id, notifications), ), }); @@ -122,7 +122,7 @@ export const monitorRouter = createTRPCRouter({ const allTags = await opts.ctx.db.query.monitorTag.findMany({ where: and( eq(monitorTag.workspaceId, opts.ctx.workspace.id), - inArray(monitorTag.id, tags) + inArray(monitorTag.id, tags), ), }); @@ -138,7 +138,7 @@ export const monitorRouter = createTRPCRouter({ const allPages = await opts.ctx.db.query.page.findMany({ where: and( eq(page.workspaceId, opts.ctx.workspace.id), - inArray(page.id, pages) + inArray(page.id, pages), ), }); @@ -165,7 +165,7 @@ export const monitorRouter = createTRPCRouter({ where: and( eq(monitor.id, opts.input.id), eq(monitor.workspaceId, opts.ctx.workspace.id), - isNull(monitor.deletedAt) + isNull(monitor.deletedAt), ), with: { monitorTagsToMonitors: { with: { monitorTag: true } }, @@ -190,7 +190,7 @@ export const monitorRouter = createTRPCRouter({ maintenance: _monitor?.maintenancesToMonitors.some( (item) => item.maintenance.from.getTime() <= Date.now() && - item.maintenance.to.getTime() >= Date.now() + item.maintenance.to.getTime() >= Date.now(), ), }); @@ -212,7 +212,7 @@ export const monitorRouter = createTRPCRouter({ where: and( eq(monitor.id, opts.input.id), isNull(monitor.deletedAt), - eq(monitor.public, true) + eq(monitor.public, true), ), }); if (!_monitor) return undefined; @@ -224,7 +224,7 @@ export const monitorRouter = createTRPCRouter({ }); const hasPageRelation = _page?.monitorsToPages.find( - ({ monitorId }) => _monitor.id === monitorId + ({ monitorId }) => _monitor.id === monitorId, ); if (!hasPageRelation) return undefined; @@ -284,8 +284,8 @@ export const monitorRouter = createTRPCRouter({ and( eq(monitor.id, opts.input.id), eq(monitor.workspaceId, opts.ctx.workspace.id), - isNull(monitor.deletedAt) - ) + isNull(monitor.deletedAt), + ), ) .returning() .get(); @@ -300,7 +300,7 @@ export const monitorRouter = createTRPCRouter({ (x) => !currentMonitorNotifications .map(({ notificationId }) => notificationId) - ?.includes(x) + ?.includes(x), ); if (addedNotifications.length > 0) { @@ -324,9 +324,9 @@ export const monitorRouter = createTRPCRouter({ eq(notificationsToMonitors.monitorId, currentMonitor.id), inArray( notificationsToMonitors.notificationId, - removedNotifications - ) - ) + removedNotifications, + ), + ), ) .run(); } @@ -341,7 +341,7 @@ export const monitorRouter = createTRPCRouter({ (x) => !currentMonitorTags .map(({ monitorTagId }) => monitorTagId) - ?.includes(x) + ?.includes(x), ); if (addedTags.length > 0) { @@ -363,8 +363,8 @@ export const monitorRouter = createTRPCRouter({ .where( and( eq(monitorTagsToMonitors.monitorId, currentMonitor.id), - inArray(monitorTagsToMonitors.monitorTagId, removedTags) - ) + inArray(monitorTagsToMonitors.monitorTagId, removedTags), + ), ) .run(); } @@ -376,7 +376,7 @@ export const monitorRouter = createTRPCRouter({ .all(); const addedPages = pages.filter( - (x) => !currentMonitorPages.map(({ pageId }) => pageId)?.includes(x) + (x) => !currentMonitorPages.map(({ pageId }) => pageId)?.includes(x), ); if (addedPages.length > 0) { @@ -398,8 +398,8 @@ export const monitorRouter = createTRPCRouter({ .where( and( eq(monitorsToPages.monitorId, currentMonitor.id), - inArray(monitorsToPages.pageId, removedPages) - ) + inArray(monitorsToPages.pageId, removedPages), + ), ) .run(); } @@ -414,8 +414,8 @@ export const monitorRouter = createTRPCRouter({ .where( and( eq(monitor.id, opts.input.id), - eq(monitor.workspaceId, opts.ctx.workspace.id) - ) + eq(monitor.workspaceId, opts.ctx.workspace.id), + ), ) .get(); if (!monitorToDelete) return; @@ -446,7 +446,7 @@ export const monitorRouter = createTRPCRouter({ const monitors = await opts.ctx.db.query.monitor.findMany({ where: and( eq(monitor.workspaceId, opts.ctx.workspace.id), - isNull(monitor.deletedAt) + isNull(monitor.deletedAt), ), with: { monitorTagsToMonitors: { with: { monitorTag: true } }, @@ -459,7 +459,7 @@ export const monitorRouter = createTRPCRouter({ monitorTagsToMonitors: z .array(z.object({ monitorTag: selectMonitorTagSchema })) .default([]), - }) + }), ) .parse(monitors); }), @@ -470,7 +470,7 @@ export const monitorRouter = createTRPCRouter({ const _page = await opts.ctx.db.query.page.findFirst({ where: and( eq(page.id, opts.input.id), - eq(page.workspaceId, opts.ctx.workspace.id) + eq(page.workspaceId, opts.ctx.workspace.id), ), }); @@ -479,7 +479,7 @@ export const monitorRouter = createTRPCRouter({ const monitors = await opts.ctx.db.query.monitor.findMany({ where: and( eq(monitor.workspaceId, opts.ctx.workspace.id), - isNull(monitor.deletedAt) + isNull(monitor.deletedAt), ), with: { monitorTagsToMonitors: { with: { monitorTag: true } }, @@ -495,14 +495,14 @@ export const monitorRouter = createTRPCRouter({ monitorTagsToMonitors: z .array(z.object({ monitorTag: selectMonitorTagSchema })) .default([]), - }) + }), ) .parse( monitors.filter((monitor) => monitor.monitorsToPages .map(({ pageId }) => pageId) - .includes(_page.id) - ) + .includes(_page.id), + ), ); }), @@ -516,8 +516,8 @@ export const monitorRouter = createTRPCRouter({ and( eq(monitor.id, opts.input.id), eq(monitor.workspaceId, opts.ctx.workspace.id), - isNull(monitor.deletedAt) - ) + isNull(monitor.deletedAt), + ), ) .get(); @@ -536,8 +536,8 @@ export const monitorRouter = createTRPCRouter({ .where( and( eq(monitor.id, opts.input.id), - eq(monitor.workspaceId, opts.ctx.workspace.id) - ) + eq(monitor.workspaceId, opts.ctx.workspace.id), + ), ) .run(); }), @@ -565,8 +565,8 @@ export const monitorRouter = createTRPCRouter({ notification, and( eq(notificationsToMonitors.notificationId, notification.id), - eq(notification.workspaceId, opts.ctx.workspace.id) - ) + eq(notification.workspaceId, opts.ctx.workspace.id), + ), ) .where(eq(notificationsToMonitors.monitorId, opts.input.id)) .all(); @@ -579,7 +579,7 @@ export const monitorRouter = createTRPCRouter({ await opts.ctx.db.query.monitor.findMany({ where: and( eq(monitor.workspaceId, opts.ctx.workspace.id), - isNull(monitor.deletedAt) + isNull(monitor.deletedAt), ), }) ).length; diff --git a/packages/api/src/router/notification.ts b/packages/api/src/router/notification.ts index 9d33bf293d..706a58f7eb 100644 --- a/packages/api/src/router/notification.ts +++ b/packages/api/src/router/notification.ts @@ -10,9 +10,9 @@ import { } from "@openstatus/db/src/schema"; import { getLimit } from "@openstatus/plans"; +import { SchemaError } from "@openstatus/error"; import { trackNewNotification } from "../analytics"; import { createTRPCRouter, protectedProcedure } from "../trpc"; -import { SchemaError } from "@openstatus/error"; export const notificationRouter = createTRPCRouter({ create: protectedProcedure @@ -22,7 +22,7 @@ export const notificationRouter = createTRPCRouter({ const notificationLimit = getLimit( opts.ctx.workspace.plan, - "notification-channels" + "notification-channels", ); const notificationNumber = ( @@ -83,8 +83,8 @@ export const notificationRouter = createTRPCRouter({ .where( and( eq(notification.id, opts.input.id), - eq(notification.workspaceId, opts.ctx.workspace.id) - ) + eq(notification.workspaceId, opts.ctx.workspace.id), + ), ) .returning() .get(); @@ -98,8 +98,8 @@ export const notificationRouter = createTRPCRouter({ .where( and( eq(notification.id, opts.input.id), - eq(notification.id, opts.input.id) - ) + eq(notification.id, opts.input.id), + ), ) .run(); }), @@ -114,8 +114,8 @@ export const notificationRouter = createTRPCRouter({ and( eq(notification.id, opts.input.id), eq(notification.id, opts.input.id), - eq(notification.workspaceId, opts.ctx.workspace.id) - ) + eq(notification.workspaceId, opts.ctx.workspace.id), + ), ) .get(); @@ -135,7 +135,7 @@ export const notificationRouter = createTRPCRouter({ isNotificationLimitReached: protectedProcedure.query(async (opts) => { const notificationLimit = getLimit( opts.ctx.workspace.plan, - "notification-channels" + "notification-channels", ); const notificationNumbers = ( await opts.ctx.db.query.notification.findMany({ diff --git a/packages/api/src/router/page.ts b/packages/api/src/router/page.ts index 859d036161..b7bd99e4d7 100644 --- a/packages/api/src/router/page.ts +++ b/packages/api/src/router/page.ts @@ -66,7 +66,7 @@ export const pageRouter = createTRPCRouter({ where: and( inArray(monitor.id, monitorIds), eq(monitor.workspaceId, opts.ctx.workspace.id), - isNull(monitor.deletedAt) + isNull(monitor.deletedAt), ), }); @@ -96,7 +96,7 @@ export const pageRouter = createTRPCRouter({ const firstPage = await opts.ctx.db.query.page.findFirst({ where: and( eq(page.id, opts.input.id), - eq(page.workspaceId, opts.ctx.workspace.id) + eq(page.workspaceId, opts.ctx.workspace.id), ), with: { monitorsToPages: { @@ -133,8 +133,8 @@ export const pageRouter = createTRPCRouter({ .where( and( eq(page.id, pageInput.id), - eq(page.workspaceId, opts.ctx.workspace.id) - ) + eq(page.workspaceId, opts.ctx.workspace.id), + ), ) .returning() .get(); @@ -145,7 +145,7 @@ export const pageRouter = createTRPCRouter({ where: and( inArray(monitor.id, monitorIds), eq(monitor.workspaceId, opts.ctx.workspace.id), - isNull(monitor.deletedAt) + isNull(monitor.deletedAt), ), }); @@ -174,8 +174,8 @@ export const pageRouter = createTRPCRouter({ .where( and( inArray(monitorsToPages.monitorId, removedMonitors), - eq(monitorsToPages.pageId, currentPage.id) - ) + eq(monitorsToPages.pageId, currentPage.id), + ), ); } @@ -203,8 +203,8 @@ export const pageRouter = createTRPCRouter({ .where( and( eq(page.id, opts.input.id), - eq(page.workspaceId, opts.ctx.workspace.id) - ) + eq(page.workspaceId, opts.ctx.workspace.id), + ), ) .run(); }), @@ -216,7 +216,7 @@ export const pageRouter = createTRPCRouter({ maintenancesToPages: { where: and( lte(maintenance.from, new Date()), - gte(maintenance.to, new Date()) + gte(maintenance.to, new Date()), ), }, }, @@ -252,12 +252,12 @@ export const pageRouter = createTRPCRouter({ .leftJoin(monitor, eq(monitorsToPages.monitorId, monitor.id)) .where( // make sur only active monitors are returned! - and(eq(monitorsToPages.pageId, result.id), eq(monitor.active, true)) + and(eq(monitorsToPages.pageId, result.id), eq(monitor.active, true)), ) .all(); const monitorsId = monitorsToPagesResult.map( - ({ monitors_to_pages }) => monitors_to_pages.monitorId + ({ monitors_to_pages }) => monitors_to_pages.monitorId, ); const monitorsToStatusReportResult = @@ -276,15 +276,15 @@ export const pageRouter = createTRPCRouter({ .all(); const monitorStatusReportIds = monitorsToStatusReportResult.map( - ({ statusReportId }) => statusReportId + ({ statusReportId }) => statusReportId, ); const pageStatusReportIds = statusReportsToPagesResult.map( - ({ statusReportId }) => statusReportId + ({ statusReportId }) => statusReportId, ); const statusReportIds = Array.from( - new Set([...monitorStatusReportIds, ...pageStatusReportIds]) + new Set([...monitorStatusReportIds, ...pageStatusReportIds]), ); const statusReports = @@ -311,8 +311,8 @@ export const pageRouter = createTRPCRouter({ and( inArray(monitor.id, monitorsId), eq(monitor.active, true), - isNull(monitor.deletedAt) - ) // REMINDER: this is hardcoded + isNull(monitor.deletedAt), + ), // REMINDER: this is hardcoded ) .all() : []; @@ -325,8 +325,8 @@ export const pageRouter = createTRPCRouter({ .where( inArray( incidentTable.monitorId, - monitors.map((m) => m.id) - ) + monitors.map((m) => m.id), + ), ) .all() : []; @@ -365,7 +365,7 @@ export const pageRouter = createTRPCRouter({ // had filter on some words we want to keep for us if ( ["api", "app", "www", "docs", "checker", "time", "help"].includes( - opts.input.slug + opts.input.slug, ) ) { return false; @@ -378,7 +378,7 @@ export const pageRouter = createTRPCRouter({ addCustomDomain: protectedProcedure .input( - z.object({ customDomain: z.string().toLowerCase(), pageId: z.number() }) + z.object({ customDomain: z.string().toLowerCase(), pageId: z.number() }), ) .mutation(async (opts) => { // TODO Add some check ? diff --git a/packages/api/src/router/rum/index.ts b/packages/api/src/router/rum/index.ts index 7306c16bd1..8c6a60dc2e 100644 --- a/packages/api/src/router/rum/index.ts +++ b/packages/api/src/router/rum/index.ts @@ -4,7 +4,7 @@ import { createTRPCRouter, protectedProcedure } from "../../trpc"; const event = z.enum(["CLS", "FCP", "FID", "INP", "LCP", "TTFB"]); -const RouteData = z.object({ +const _RouteData = z.object({ href: z.string(), total_event: z.coerce.number(), clsValue: z.number().optional(), @@ -19,14 +19,14 @@ export const rumRouter = createTRPCRouter({ .input( z.object({ event: event, - }) + }), ) - .query((opts) => { + .query((_opts) => { // FIXME: Use tb pipe instead return null; }), - GetAggregatedPerPage: protectedProcedure.query((opts) => { + GetAggregatedPerPage: protectedProcedure.query((_opts) => { // FIXME: Use tb pipe instead return null; }), diff --git a/packages/api/src/router/tinybird/index.ts b/packages/api/src/router/tinybird/index.ts index 6f89afb8a7..d822c5ed3f 100644 --- a/packages/api/src/router/tinybird/index.ts +++ b/packages/api/src/router/tinybird/index.ts @@ -29,7 +29,7 @@ export const tinybirdRouter = createTRPCRouter({ url: z.string().url().optional(), region: z.enum(flyRegions).optional(), cronTimestamp: z.number().int().optional(), - }) + }), ) .query(async (opts) => { return await tb.endpointResponseDetails("7d")(opts.input); @@ -52,7 +52,7 @@ export const tinybirdRouter = createTRPCRouter({ dsn: z.string(), path: z.string(), period: z.enum(["24h", "7d", "30d"]), - }) + }), ) .query(async (opts) => { return await tb.applicationRUMMetricsForPath()(opts.input); @@ -63,7 +63,7 @@ export const tinybirdRouter = createTRPCRouter({ dsn: z.string(), path: z.string(), period: z.enum(["24h", "7d", "30d"]), - }) + }), ) .query(async (opts) => { return await tb.applicationSessionMetricsPerPath()(opts.input); diff --git a/packages/api/src/router/workspace.ts b/packages/api/src/router/workspace.ts index 2e0d43dda6..3e4e44c381 100644 --- a/packages/api/src/router/workspace.ts +++ b/packages/api/src/router/workspace.ts @@ -124,7 +124,7 @@ export const workspaceRouter = createTRPCRouter({ await opts.ctx.db.query.usersToWorkspaces.findFirst({ where: and( eq(usersToWorkspaces.userId, opts.ctx.user.id), - eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id) + eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id), ), }); @@ -141,8 +141,8 @@ export const workspaceRouter = createTRPCRouter({ .where( and( eq(usersToWorkspaces.userId, opts.input.id), - eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id) - ) + eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id), + ), ) .run(); }), @@ -154,7 +154,7 @@ export const workspaceRouter = createTRPCRouter({ await opts.ctx.db.query.usersToWorkspaces.findFirst({ where: and( eq(usersToWorkspaces.userId, opts.ctx.user.id), - eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id) + eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id), ), }); diff --git a/packages/db/src/schema/applications/application.ts b/packages/db/src/schema/applications/application.ts index 44f5142481..8bb55029b1 100644 --- a/packages/db/src/schema/applications/application.ts +++ b/packages/db/src/schema/applications/application.ts @@ -10,9 +10,9 @@ export const application = sqliteTable("application", { workspaceId: integer("workspace_id").references(() => workspace.id), createdAt: integer("created_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), updatedAt: integer("updated_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), }); diff --git a/packages/db/src/schema/maintenances/maintenance.ts b/packages/db/src/schema/maintenances/maintenance.ts index 8c4b54d6b7..ff9d633979 100644 --- a/packages/db/src/schema/maintenances/maintenance.ts +++ b/packages/db/src/schema/maintenances/maintenance.ts @@ -6,9 +6,9 @@ import { text, } from "drizzle-orm/sqlite-core"; +import { monitor } from "../monitors"; import { page } from "../pages"; import { workspace } from "../workspaces"; -import { monitor } from "../monitors"; export const maintenance = sqliteTable("maintenance", { id: integer("id").primaryKey(), @@ -22,10 +22,10 @@ export const maintenance = sqliteTable("maintenance", { pageId: integer("page_id").references(() => page.id), createdAt: integer("created_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), updatedAt: integer("updated_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), }); @@ -39,12 +39,12 @@ export const maintenancesToMonitors = sqliteTable( .notNull() .references(() => maintenance.id, { onDelete: "cascade" }), createdAt: integer("created_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), }, (t) => ({ pk: primaryKey(t.monitorId, t.maintenanceId), - }) + }), ); export const maintenancesToMonitorsRelations = relations( @@ -58,7 +58,7 @@ export const maintenancesToMonitorsRelations = relations( fields: [maintenancesToMonitors.maintenanceId], references: [maintenance.id], }), - }) + }), ); export const maintenanceRelations = relations(maintenance, ({ one, many }) => ({ diff --git a/packages/db/src/schema/maintenances/validation.ts b/packages/db/src/schema/maintenances/validation.ts index 8906d2967f..c0db1674d1 100644 --- a/packages/db/src/schema/maintenances/validation.ts +++ b/packages/db/src/schema/maintenances/validation.ts @@ -1,6 +1,6 @@ import { createInsertSchema, createSelectSchema } from "drizzle-zod"; -import { maintenance } from "./maintenance"; import { z } from "zod"; +import { maintenance } from "./maintenance"; export const insertMaintenanceSchema = createInsertSchema(maintenance) .extend({ diff --git a/packages/db/src/schema/monitors/monitor.ts b/packages/db/src/schema/monitors/monitor.ts index 73549c49ec..7ced1b6cc6 100644 --- a/packages/db/src/schema/monitors/monitor.ts +++ b/packages/db/src/schema/monitors/monitor.ts @@ -6,6 +6,7 @@ import { text, } from "drizzle-orm/sqlite-core"; +import { maintenancesToMonitors } from "../maintenances"; import { monitorTagsToMonitors } from "../monitor_tags"; import { notificationsToMonitors } from "../notifications"; import { page } from "../pages"; @@ -17,7 +18,6 @@ import { monitorPeriodicity, monitorStatus, } from "./constants"; -import { maintenancesToMonitors } from "../maintenances"; export const monitor = sqliteTable("monitor", { id: integer("id").primaryKey(), @@ -47,10 +47,10 @@ export const monitor = sqliteTable("monitor", { public: integer("public", { mode: "boolean" }).default(false), createdAt: integer("created_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), updatedAt: integer("updated_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), deletedAt: integer("deleted_at", { mode: "timestamp" }), @@ -78,13 +78,13 @@ export const monitorsToPages = sqliteTable( .notNull() .references(() => page.id, { onDelete: "cascade" }), createdAt: integer("created_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), order: integer("order").default(0), }, (t) => ({ pk: primaryKey(t.monitorId, t.pageId), - }) + }), ); export const monitorsToPagesRelation = relations( @@ -98,5 +98,5 @@ export const monitorsToPagesRelation = relations( fields: [monitorsToPages.pageId], references: [page.id], }), - }) + }), ); diff --git a/packages/db/src/schema/pages/page.ts b/packages/db/src/schema/pages/page.ts index be901fc117..ebe2e9cc7f 100644 --- a/packages/db/src/schema/pages/page.ts +++ b/packages/db/src/schema/pages/page.ts @@ -1,10 +1,10 @@ import { relations, sql } from "drizzle-orm"; import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; +import { maintenance } from "../maintenances"; import { monitorsToPages } from "../monitors"; import { pagesToStatusReports } from "../status_reports"; import { workspace } from "../workspaces"; -import { maintenance } from "../maintenances"; export const page = sqliteTable("page", { id: integer("id").primaryKey(), @@ -23,14 +23,14 @@ export const page = sqliteTable("page", { // Password protecting the status page - no specific restriction on password password: text("password", { length: 256 }), passwordProtected: integer("password_protected", { mode: "boolean" }).default( - false + false, ), createdAt: integer("created_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), updatedAt: integer("updated_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), }); diff --git a/packages/db/src/schema/shared.ts b/packages/db/src/schema/shared.ts index 54f3722eec..e1a8570a78 100644 --- a/packages/db/src/schema/shared.ts +++ b/packages/db/src/schema/shared.ts @@ -1,6 +1,10 @@ import { z } from "zod"; import { selectIncidentSchema } from "./incidents/validation"; +import { + maintenancesToMonitors, + selectMaintenanceSchema, +} from "./maintenances"; import { selectMonitorSchema } from "./monitors"; import { selectPageSchema } from "./pages"; import { @@ -8,10 +12,6 @@ import { selectStatusReportUpdateSchema, } from "./status_reports"; import { workspacePlanSchema } from "./workspaces"; -import { - maintenancesToMonitors, - selectMaintenanceSchema, -} from "./maintenances"; // TODO: create a 'public-status' schema with all the different types and validations @@ -29,7 +29,7 @@ export const selectStatusReportPageSchema = selectStatusReportSchema.extend({ monitorId: z.number(), statusReportId: z.number(), monitor: selectPublicMonitorSchema, - }) + }), ) .default([]), }); @@ -40,7 +40,7 @@ export const selectMaintenancePageSchema = selectMaintenanceSchema.extend({ z.object({ monitorId: z.number(), maintenanceId: z.number(), - }) + }), ) .default([]), }); @@ -59,7 +59,7 @@ export const selectPageSchemaWithMonitorsRelation = selectPageSchema.extend({ pageId: z.number(), order: z.number().default(0).optional(), monitor: selectMonitorSchema, - }) + }), ), maintenancesToPages: selectMaintenanceSchema.array().default([]), }); @@ -88,7 +88,7 @@ export const selectPublicStatusReportSchemaWithRelation = monitorId: z.number(), statusReportId: z.number(), monitor: selectPublicMonitorSchema, - }) + }), ) .default([]), statusReportUpdates: z.array(selectStatusReportUpdateSchema), diff --git a/packages/db/src/schema/workspaces/workspace.ts b/packages/db/src/schema/workspaces/workspace.ts index cd4aeed082..ebcf3f834b 100644 --- a/packages/db/src/schema/workspaces/workspace.ts +++ b/packages/db/src/schema/workspaces/workspace.ts @@ -19,17 +19,17 @@ export const workspace = sqliteTable( paidUntil: integer("paid_until", { mode: "timestamp" }), createdAt: integer("created_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), updatedAt: integer("updated_at", { mode: "timestamp" }).default( - sql`(strftime('%s', 'now'))` + sql`(strftime('%s', 'now'))`, ), dsn: text("dsn"), // should be removed soon }, (t) => ({ unique: unique().on(t.id, t.dsn), - }) + }), ); export const workspaceRelations = relations(workspace, ({ many }) => ({ diff --git a/packages/emails/emails/followup.tsx b/packages/emails/emails/followup.tsx index e1a9036365..461cef22d9 100644 --- a/packages/emails/emails/followup.tsx +++ b/packages/emails/emails/followup.tsx @@ -26,8 +26,7 @@ const FollowUpEmail = () => {

⭐ Star us on{" "} GitHub -
- 🚀 Visit our website{" "} +
🚀 Visit our website{" "} OpenStatus.dev diff --git a/packages/emails/emails/welcome.tsx b/packages/emails/emails/welcome.tsx index 32e229977b..651e6351ff 100644 --- a/packages/emails/emails/welcome.tsx +++ b/packages/emails/emails/welcome.tsx @@ -26,9 +26,7 @@ const WelcomeEmail = () => { {" "} to manage your monitors
- Integrate your status within your application with our{" "} - - API - {" "} + API{" "} and{" "} React Widget
- Build your own status page with our{" "} @@ -50,8 +48,7 @@ const WelcomeEmail = () => {

⭐ Star us on{" "} GitHub -
- 🚀 Visit our website{" "} +
🚀 Visit our website{" "} OpenStatus.dev diff --git a/packages/error/src/base-error.ts b/packages/error/src/base-error.ts index 0f22f9b950..c986193900 100644 --- a/packages/error/src/base-error.ts +++ b/packages/error/src/base-error.ts @@ -3,7 +3,7 @@ import type { ErrorCode } from "./error-code"; type ErrorContext = Record; export abstract class BaseError< - TContext extends ErrorContext = ErrorContext + TContext extends ErrorContext = ErrorContext, > extends Error { public abstract readonly name: string; /** @@ -35,7 +35,7 @@ export abstract class BaseError< return `${this.name}(${this.code}): ${ this.message } - caused by ${this.cause?.toString()} - with context ${JSON.stringify( - this.context + this.context, )}`; } diff --git a/packages/error/src/utils.ts b/packages/error/src/utils.ts index e62342ba39..d437d09374 100644 --- a/packages/error/src/utils.ts +++ b/packages/error/src/utils.ts @@ -55,8 +55,8 @@ export function parseZodErrorIssues(issues: ZodIssue[]): string { i.code === "invalid_union" ? i.unionErrors.map((ue) => parseZodErrorIssues(ue.issues)).join("; ") : i.code === "unrecognized_keys" - ? i.message - : `${i.path.length ? `${i.code} in '${i.path}': ` : ""}${i.message}` + ? i.message + : `${i.path.length ? `${i.code} in '${i.path}': ` : ""}${i.message}`, ) .join("; "); } diff --git a/packages/plans/src/utils.ts b/packages/plans/src/utils.ts index 00f46d3378..969c763fe1 100644 --- a/packages/plans/src/utils.ts +++ b/packages/plans/src/utils.ts @@ -6,7 +6,7 @@ import type { Limits } from "./types"; // TODO: use getLimit utils function export function getLimit( plan: WorkspacePlan, - limit: T + limit: T, ) { return allPlans[plan].limits[limit]; } diff --git a/packages/react/src/widget.tsx b/packages/react/src/widget.tsx index d1bfc2135d..6946f7109f 100644 --- a/packages/react/src/widget.tsx +++ b/packages/react/src/widget.tsx @@ -45,12 +45,10 @@ export async function StatusWidget({ slug, href }: StatusWidgetProps) { {status === "operational" ? ( ) : null} - + ); diff --git a/packages/tinybird/src/os-client.ts b/packages/tinybird/src/os-client.ts index ad8900db41..f8ae3b27b3 100644 --- a/packages/tinybird/src/os-client.ts +++ b/packages/tinybird/src/os-client.ts @@ -16,7 +16,7 @@ const DEV_CACHE = 3_600; // 1h const MIN_CACHE = isProd ? 60 : DEV_CACHE; // 60s const DEFAULT_CACHE = isProd ? 120 : DEV_CACHE; // 2min -const MAX_CACHE = 86_400; // 1d +const _MAX_CACHE = 86_400; // 1d const VERSION = "v1"; @@ -118,7 +118,7 @@ export class OSTinybird { opts?: { cache?: RequestCache | undefined; revalidate: number | undefined; - } // RETHINK: not the best way to handle it + }, // RETHINK: not the best way to handle it ) => { try { const res = await this.tb.buildPipe({ @@ -178,7 +178,7 @@ export class OSTinybird { endpointStatusPeriod( period: "7d" | "45d", - timezone: "UTC" = "UTC" // "EST" | "PST" | "CET" + timezone: "UTC" = "UTC", // "EST" | "PST" | "CET" ) { const parameters = z.object({ monitorId: z.string() }); @@ -187,7 +187,7 @@ export class OSTinybird { opts?: { cache?: RequestCache | undefined; revalidate: number | undefined; - } // RETHINK: not the best way to handle it + }, // RETHINK: not the best way to handle it ) => { try { const res = await this.tb.buildPipe({ diff --git a/packages/tracker/src/tracker.ts b/packages/tracker/src/tracker.ts index 82b26b4327..f3ccc1f6b4 100644 --- a/packages/tracker/src/tracker.ts +++ b/packages/tracker/src/tracker.ts @@ -56,7 +56,7 @@ export class Tracker { prev.count += curr.count; return prev; }, - { count: 0, ok: 0 } + { count: 0, ok: 0 }, ); } @@ -80,7 +80,7 @@ export class Tracker { private isOngoingReport() { const resolved: StatusReport["status"][] = ["monitoring", "resolved"]; return this.statusReports.some( - (report) => !resolved.includes(report.status) + (report) => !resolved.includes(report.status), ); } @@ -152,7 +152,7 @@ export class Tracker { private getStatusReportsByDay(props: Monitor): StatusReports { const statusReports = this.statusReports?.filter((report) => { const firstStatusReportUpdate = report?.statusReportUpdates?.sort( - (a, b) => a.date.getTime() - b.date.getTime() + (a, b) => a.date.getTime() - b.date.getTime(), )?.[0]; if (!firstStatusReportUpdate) return false; @@ -191,10 +191,10 @@ export class Tracker { const status = maintenances.length ? Status.UnderMaintenance : incidents.length - ? Status.Incident - : isMissingData - ? Status.Unknown - : this.calculateUptimeStatus([props]); + ? Status.Incident + : isMissingData + ? Status.Unknown + : this.calculateUptimeStatus([props]); const variant = statusDetails[status].variant; const label = statusDetails[status].short;