mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-07 03:27:29 +02:00
🔒️ Fix middleware logic
This commit is contained in:
parent
532410d76c
commit
b9cbb61afc
1 changed files with 10 additions and 13 deletions
|
@ -14,7 +14,6 @@ import { kv } from "@vercel/kv";
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
import { rateLimiter } from "hono-rate-limiter";
|
import { rateLimiter } from "hono-rate-limiter";
|
||||||
import { bearerAuth } from "hono/bearer-auth";
|
import { bearerAuth } from "hono/bearer-auth";
|
||||||
import { some } from "hono/combine";
|
|
||||||
import { handle } from "hono/vercel";
|
import { handle } from "hono/vercel";
|
||||||
|
|
||||||
const isKvAvailable =
|
const isKvAvailable =
|
||||||
|
@ -33,18 +32,16 @@ if (env.LICENSE_API_AUTH_TOKEN) {
|
||||||
app.post(
|
app.post(
|
||||||
"/licenses",
|
"/licenses",
|
||||||
zValidator("json", createLicenseInputSchema),
|
zValidator("json", createLicenseInputSchema),
|
||||||
some(
|
rateLimiter({
|
||||||
bearerAuth({ token: env.LICENSE_API_AUTH_TOKEN }),
|
windowMs: 60 * 60 * 1000,
|
||||||
rateLimiter({
|
limit: 10,
|
||||||
windowMs: 60 * 60 * 1000,
|
store: isKvAvailable
|
||||||
limit: 10,
|
? new RedisStore({
|
||||||
store: isKvAvailable
|
client: kv,
|
||||||
? new RedisStore({
|
})
|
||||||
client: kv,
|
: undefined,
|
||||||
})
|
}),
|
||||||
: undefined,
|
bearerAuth({ token: env.LICENSE_API_AUTH_TOKEN }),
|
||||||
}),
|
|
||||||
),
|
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const { type, seats, expiresAt, licenseeEmail, licenseeName, version } =
|
const { type, seats, expiresAt, licenseeEmail, licenseeName, version } =
|
||||||
c.req.valid("json");
|
c.req.valid("json");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue