Skip to content

Commit 3ea9f0e

Browse files
committed
fix: remove autumn cache
1 parent 88c6029 commit 3ea9f0e

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

apps/basket/src/lib/request-validation.ts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { cacheable } from "@databuddy/redis";
21
import { Autumn as autumn } from "autumn-js";
32
import { getWebsiteByIdV2, isValidOrigin } from "../hooks/auth";
43
import { extractIpFromRequest } from "../utils/ip-geo";
@@ -24,23 +23,6 @@ type ValidationError = {
2423
error: { status: string; message: string };
2524
};
2625

27-
const checkAutumnCached = cacheable(
28-
async (ownerId: string) => {
29-
const result = await autumn.check({
30-
customer_id: ownerId,
31-
feature_id: "events",
32-
send_event: true,
33-
});
34-
return result.data;
35-
},
36-
{
37-
expireInSec: 60,
38-
prefix: "autumn_check_events",
39-
staleWhileRevalidate: true,
40-
staleTime: 30,
41-
}
42-
);
43-
4426
/**
4527
* Validate incoming request for analytics events
4628
*/
@@ -116,7 +98,12 @@ export function validateRequest(
11698

11799
if (website.ownerId) {
118100
try {
119-
const data = await checkAutumnCached(website.ownerId);
101+
const result = await autumn.check({
102+
customer_id: website.ownerId,
103+
feature_id: "events",
104+
send_event: true,
105+
});
106+
const data = result.data;
120107

121108
if (data && !(data.allowed || data.overage_allowed)) {
122109
logBlockedTraffic(

packages/rpc/src/routers/apikeys.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ export const apikeysRouter = {
249249
input.organizationId
250250
? eq(apikey.organizationId, input.organizationId)
251251
: and(
252-
eq(apikey.userId, context.user.id),
253-
isNull(apikey.organizationId)
254-
)
252+
eq(apikey.userId, context.user.id),
253+
isNull(apikey.organizationId)
254+
)
255255
)
256256
.orderBy(desc(apikey.createdAt));
257257

0 commit comments

Comments
 (0)