Skip to content

Commit c92c2c3

Browse files
committed
refactor: improve logging and configuration in upload-file and auth-client
- Added console log statements in the uploadFile function to enhance traceability during execution, including checks for S3 client availability and input parsing. - Configured the authClient to use the baseURL from environment variables, ensuring proper authentication handling across different environments.
1 parent 22cf81a commit c92c2c3

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

apps/app/src/actions/files/upload-file.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ const uploadAttachmentSchema = z.object({
5050
});
5151

5252
export const uploadFile = async (input: z.infer<typeof uploadAttachmentSchema>) => {
53+
console.log('[uploadFile] Function called - starting execution');
5354
logger.info(`[uploadFile] Starting upload for ${input.fileName}`);
55+
56+
console.log('[uploadFile] Checking S3 client availability');
5457
try {
5558
// Check if S3 client is available
5659
if (!s3Client) {
@@ -69,9 +72,11 @@ export const uploadFile = async (input: z.infer<typeof uploadAttachmentSchema>)
6972
} as const;
7073
}
7174

75+
console.log('[uploadFile] Parsing input schema');
7276
const { fileName, fileType, fileData, entityId, entityType, pathToRevalidate } =
7377
uploadAttachmentSchema.parse(input);
7478

79+
console.log('[uploadFile] Getting user session');
7580
const session = await auth.api.getSession({ headers: await headers() });
7681
const organizationId = session?.session.activeOrganizationId;
7782

@@ -85,6 +90,7 @@ export const uploadFile = async (input: z.infer<typeof uploadAttachmentSchema>)
8590

8691
logger.info(`[uploadFile] Starting upload for ${fileName} in org ${organizationId}`);
8792

93+
console.log('[uploadFile] Converting file data to buffer');
8894
const fileBuffer = Buffer.from(fileData, 'base64');
8995

9096
const MAX_FILE_SIZE_MB = 10;

apps/app/src/utils/auth-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { auth } from './auth';
99
import { ac, allRoles } from './permissions';
1010

1111
export const authClient = createAuthClient({
12+
baseURL: process.env.NEXT_PUBLIC_BETTER_AUTH_URL,
1213
plugins: [
1314
organizationClient({
1415
ac,

0 commit comments

Comments
 (0)