Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/shrihari-prakash/liquid int…
Browse files Browse the repository at this point in the history
…o release
  • Loading branch information
shrihari-prakash committed Oct 31, 2023
2 parents 335f37e + 8f8aed0 commit 99c81a4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/service/api/user/admin-api/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import GET_UserInfo, { GET_UserInfoValidator } from "../shared/user-info.get";
import GET_EditableFields from "./editable-fields.get";
import GET_Roles from "../shared/roles.get";
import PATCH_User, { PATCH_UserValidator } from "./user.patch";
import GET_SubscriptionTiers from "../shared/subscription-tiers.get";

const AdminApiRouter = express.Router();

Expand All @@ -28,6 +29,7 @@ AdminApiRouter.post("/credits", ...DelegatedAuthFlow, POST_CreditsValidator, POS
AdminApiRouter.post("/restrict", ...DelegatedAuthFlow, POST_RestrictValidator, POST_Restrict);
AdminApiRouter.post("/verify", ...DelegatedAuthFlow, POST_VerifyValidator, POST_Verify);
AdminApiRouter.post("/subscription", ...DelegatedAuthFlow, POST_SubscriptionValidator, POST_Subscription);
AdminApiRouter.get("/subscription-tiers", ...DelegatedAuthFlow, GET_SubscriptionTiers);
AdminApiRouter.post("/create", ...DelegatedAuthFlow, POST_CreateValidator, POST_Create);
AdminApiRouter.get("/list", ...DelegatedAuthFlow, GET_List);

Expand Down
29 changes: 29 additions & 0 deletions src/service/api/user/shared/subscription-tiers.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Logger } from "../../../../singleton/logger";
const log = Logger.getLogger().child({ from: "admin-api/editable-fields" });

import { Request, Response } from "express";

import { errorMessages, statusCodes } from "../../../../utils/http-status";
import { ErrorResponse, SuccessResponse } from "../../../../utils/response";
import { Configuration } from "../../../../singleton/configuration";
import { ScopeManager } from "../../../../singleton/scope-manager";

const GET_SubscriptionTiers = async (_: Request, res: Response) => {
try {
if (!ScopeManager.isScopeAllowedForSharedSession("<ENTITY>:configuration:read", res)) {
return;
}
const subscriptionTiersFromConfiguration = Configuration.get("user.subscription.tier-list");
const subscriptionTiers = [];
for (let i = 0; i < subscriptionTiersFromConfiguration.length; i++) {
const tier = subscriptionTiersFromConfiguration[i];
subscriptionTiers.push({ name: tier });
}
res.status(statusCodes.success).json(new SuccessResponse({ subscriptionTiers: subscriptionTiers }));
} catch (err) {
log.error(err);
return res.status(statusCodes.internalError).json(new ErrorResponse(errorMessages.internalError));
}
};

export default GET_SubscriptionTiers;

0 comments on commit 99c81a4

Please sign in to comment.