File tree Expand file tree Collapse file tree 2 files changed +9
-22
lines changed
Expand file tree Collapse file tree 2 files changed +9
-22
lines changed Original file line number Diff line number Diff line change 1- import { cacheable } from "@databuddy/redis" ;
21import { Autumn as autumn } from "autumn-js" ;
32import { getWebsiteByIdV2 , isValidOrigin } from "../hooks/auth" ;
43import { 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 (
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments