Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/server/src/routes/v1/incidents/get_all.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test("return empty incidents", async () => {
const res = await app.request("/v1/incident", {
method: "GET",
headers: {
"x-openstatus-key": "2",
"x-openstatus-key": "3",
},
});

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/routes/v1/maintenances/get_all.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test("return empty maintenances", async () => {
const res = await app.request("/v1/maintenance", {
method: "GET",
headers: {
"x-openstatus-key": "2",
"x-openstatus-key": "3",
},
});

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/routes/v1/notifications/get_all.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test("return empty notifications", async () => {
const res = await app.request("/v1/notification", {
method: "GET",
headers: {
"x-openstatus-key": "2",
"x-openstatus-key": "3",
},
});

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/routes/v1/pages/get_all.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test("return empty pages", async () => {
const res = await app.request("/v1/page", {
method: "GET",
headers: {
"x-openstatus-key": "2",
"x-openstatus-key": "3",
},
});

Expand Down
30 changes: 15 additions & 15 deletions apps/server/src/routes/v1/pages/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,6 @@ export function registerPostPage(api: typeof pagesApi) {
});
}

const count = (
await db
.select({ count: sql<number>`count(*)` })
.from(page)
.where(eq(page.workspaceId, workspaceId))
.all()
)[0].count;

if (count >= limits["status-pages"]) {
throw new OpenStatusApiError({
code: "PAYMENT_REQUIRED",
message: "Upgrade for more status pages",
});
}

if (
!limits["password-protection"] &&
(input?.passwordProtected || input?.password)
Expand Down Expand Up @@ -110,6 +95,21 @@ export function registerPostPage(api: typeof pagesApi) {
});
}

const count = (
await db
.select({ count: sql<number>`count(*)` })
.from(page)
.where(eq(page.workspaceId, workspaceId))
.all()
)[0].count;

if (count >= limits["status-pages"]) {
throw new OpenStatusApiError({
code: "PAYMENT_REQUIRED",
message: "Upgrade for more status pages",
});
}

if (subdomainSafeList.includes(input.slug)) {
throw new OpenStatusApiError({
code: "BAD_REQUEST",
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/routes/v1/statusReports/get_all.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test("return empty status reports", async () => {
const res = await app.request("/v1/status_report", {
method: "GET",
headers: {
"x-openstatus-key": "2",
"x-openstatus-key": "3",
},
});

Expand Down