@@ -4,7 +4,6 @@ import { and, desc, eq, flags, isNull } from "@databuddy/db";
44import { createDrizzleCache , redis } from "@databuddy/redis" ;
55import { ORPCError } from "@orpc/server" ;
66import { z } from "zod" ;
7- import { logger } from "../lib/logger" ;
87import type { Context } from "../orpc" ;
98import { protectedProcedure , publicProcedure } from "../orpc" ;
109import { authorizeWebsiteAccess } from "../utils/auth" ;
@@ -177,7 +176,12 @@ export const flagsRouter = {
177176 ttl : CACHE_DURATION ,
178177 tables : [ "flags" ] ,
179178 queryFn : async ( ) => {
180- await authorizeScope ( context , input . websiteId , input . organizationId , "read" ) ;
179+ await authorizeScope (
180+ context ,
181+ input . websiteId ,
182+ input . organizationId ,
183+ "read"
184+ ) ;
181185
182186 const conditions = [
183187 isNull ( flags . deletedAt ) ,
@@ -208,7 +212,12 @@ export const flagsRouter = {
208212 ttl : CACHE_DURATION ,
209213 tables : [ "flags" ] ,
210214 queryFn : async ( ) => {
211- await authorizeScope ( context , input . websiteId , input . organizationId , "read" ) ;
215+ await authorizeScope (
216+ context ,
217+ input . websiteId ,
218+ input . organizationId ,
219+ "read"
220+ ) ;
212221
213222 const result = await context . db
214223 . select ( )
@@ -244,7 +253,12 @@ export const flagsRouter = {
244253 ttl : CACHE_DURATION ,
245254 tables : [ "flags" ] ,
246255 queryFn : async ( ) => {
247- await authorizeScope ( context , input . websiteId , input . organizationId , "read" ) ;
256+ await authorizeScope (
257+ context ,
258+ input . websiteId ,
259+ input . organizationId ,
260+ "read"
261+ ) ;
248262
249263 const result = await context . db
250264 . select ( )
@@ -326,17 +340,6 @@ export const flagsRouter = {
326340
327341 await flagsCache . invalidateByTables ( [ "flags" ] ) ;
328342
329- logger . info (
330- {
331- flagId : restoredFlag . id ,
332- key : input . key ,
333- websiteId : input . websiteId ,
334- organizationId : input . organizationId ,
335- userId : context . user . id ,
336- } ,
337- "Flag restored from soft-delete"
338- ) ;
339-
340343 return restoredFlag ;
341344 }
342345
@@ -363,17 +366,6 @@ export const flagsRouter = {
363366
364367 await flagsCache . invalidateByTables ( [ "flags" ] ) ;
365368
366- logger . info (
367- {
368- flagId : newFlag . id ,
369- key : input . key ,
370- websiteId : input . websiteId ,
371- organizationId : input . organizationId ,
372- userId : context . user . id ,
373- } ,
374- "Flag created"
375- ) ;
376-
377369 return newFlag ;
378370 } ) ,
379371
@@ -422,16 +414,6 @@ export const flagsRouter = {
422414
423415 await invalidateFlagCache ( id , flag . websiteId , flag . organizationId ) ;
424416
425- logger . info (
426- {
427- flagId : id ,
428- websiteId : flag . websiteId ,
429- organizationId : flag . organizationId ,
430- userId : context . user . id ,
431- } ,
432- "Flag updated"
433- ) ;
434-
435417 return updatedFlag ;
436418 } ) ,
437419
@@ -478,16 +460,6 @@ export const flagsRouter = {
478460
479461 await invalidateFlagCache ( input . id , flag . websiteId , flag . organizationId ) ;
480462
481- logger . info (
482- {
483- flagId : input . id ,
484- websiteId : flag . websiteId ,
485- organizationId : flag . organizationId ,
486- userId : context . user . id ,
487- } ,
488- "Flag deleted"
489- ) ;
490-
491463 return { success : true } ;
492464 } ) ,
493465} ;
0 commit comments