mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 18:33:01 +00:00
Free/Pro plan limitations
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import { IssueCreateRequestSchema } from "@sprint/shared";
|
||||
import type { AuthedRequest } from "../../auth/middleware";
|
||||
import { createIssue, getOrganisationMemberRole, getProjectByID } from "../../db/queries";
|
||||
import {
|
||||
createIssue,
|
||||
FREE_TIER_LIMITS,
|
||||
getOrganisationIssueCount,
|
||||
getOrganisationMemberRole,
|
||||
getProjectByID,
|
||||
getUserById,
|
||||
} from "../../db/queries";
|
||||
import { errorResponse, parseJsonBody } from "../../validation";
|
||||
|
||||
export default async function issueCreate(req: AuthedRequest) {
|
||||
@@ -26,6 +33,19 @@ export default async function issueCreate(req: AuthedRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// check free tier limit
|
||||
const user = await getUserById(req.userId);
|
||||
if (user && user.plan !== "pro") {
|
||||
const issueCount = await getOrganisationIssueCount(project.organisationId);
|
||||
if (issueCount >= FREE_TIER_LIMITS.issuesPerOrganisation) {
|
||||
return errorResponse(
|
||||
`free tier is limited to ${FREE_TIER_LIMITS.issuesPerOrganisation} issues per organisation. upgrade to pro for unlimited issues.`,
|
||||
"FREE_TIER_ISSUE_LIMIT",
|
||||
403,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const issue = await createIssue(
|
||||
project.id,
|
||||
title,
|
||||
|
||||
Reference in New Issue
Block a user