Skip to content

Commit

Permalink
use policy option enum in setup policies
Browse files Browse the repository at this point in the history
  • Loading branch information
gladwindos committed Mar 5, 2024
1 parent 1e04772 commit e76b45b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/server/src/router/setup-policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ export const setupPolicies = (

const { cors, jwt, apiKey, rateLimit } = policyDefinitions;

if (cors && policies.includes("cors" as PolicyOption)) {
if (cors && policies.includes(PolicyOption.Cors)) {
router.use(endpoint.path, policyMiddleware.cors(cors));
}

if (jwt && policies.includes("jwt" as PolicyOption)) {
if (jwt && policies.includes(PolicyOption.Jwt)) {
router.use(endpoint.path, policyMiddleware.jwt(jwt));
}

if (apiKey && policies.includes("apiKey" as PolicyOption)) {
if (apiKey && policies.includes(PolicyOption.ApiKey)) {
router.use(endpoint.path, policyMiddleware.apiKey(apiKey));
}

if (rateLimit && policies.includes("rateLimit" as PolicyOption)) {
if (rateLimit && policies.includes(PolicyOption.RateLimit)) {
router.use(endpoint.path, policyMiddleware.rateLimit(rateLimit));
}
}
Expand Down

0 comments on commit e76b45b

Please sign in to comment.