Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
✨ Add support for disabling billing
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Sep 8, 2020
1 parent 35ffd15 commit ff44de6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/controllers/groups/_id/billing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { ClassMiddleware, Get, Patch, Request, Response } from "@staart/server";
import {
ClassMiddleware,
Get,
Patch,
Request,
Response,
NextFunction,
} from "@staart/server";
import { Joi, joiValidate } from "@staart/validate";
import { authHandler } from "../../../_staart/helpers/middleware";
import { twtToId, localsToTokenOrKey } from "../../../_staart/helpers/utils";
Expand All @@ -7,8 +14,17 @@ import {
getGroupPricingPlansForUser,
updateGroupBillingForUser,
} from "../../../_staart/rest/group";
import { config } from "@anandchowdhary/cosmic";
import { safeError } from "../../../_staart/helpers/errors";

@ClassMiddleware(authHandler)
@ClassMiddleware(async (_: Request, res: Response, next: NextFunction) => {
if (!config("enableStripePayments")) {
const error = safeError("404/billing-not-enabled");
res.status(error.status);
return res.json(error);
} else return next();
})
export class GroupBillingController {
@Get()
async getBilling(req: Request, res: Response) {
Expand Down

0 comments on commit ff44de6

Please sign in to comment.