Skip to content

Commit

Permalink
chore(klesia): adjust rate limiter
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnk committed Sep 3, 2024
1 parent 41f8605 commit c9eda78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion apps/klesia/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ const api = new OpenAPIHono();
api.use(logger());
api.use(
rateLimiter({
keyGenerator: (c) => getConnInfo(c).remote.address ?? nanoid(),
skip: (c) => c.req.path !== "/api" || c.req.method !== "POST",
keyGenerator: (c) =>
c.req.header("x-forwarded-for") ??
getConnInfo(c).remote.address ??
nanoid(),
limit: 10,
}),
);
Expand Down
6 changes: 4 additions & 2 deletions packages/klesia-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { z } from "zod";

const NetworkMatcher = z.enum(["mainnet", "devnet"]);

export const createClient = ({ network }: { network: 'mainnet' | 'devnet' }) => {
export const createClient = ({
network,
}: { network: "mainnet" | "devnet" }) => {
return match(NetworkMatcher.parse(network))
.with("devnet", () =>
hc<KlesiaRpc>("https://devnet.klesia.palladians.xyz/api"),
)
.with("mainnet", () =>
hc<KlesiaRpc>("https://mainnet.klesia.palladians.xyz/api"),
)
.exhaustive();
.exhaustive();
};

0 comments on commit c9eda78

Please sign in to comment.