Skip to content

Commit 22cf81a

Browse files
committed
refactor: enhance logging in upload-file and S3 modules
- Added detailed console log statements in the upload-file and S3 modules to improve traceability during module loading and import processes. - Included the baseURL in the auth configuration to ensure proper handling of authentication requests across different environments.
1 parent 5a74e07 commit 22cf81a

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
'use server';
22

3+
console.log('[uploadFile] Upload action module is being loaded...');
4+
5+
console.log('[uploadFile] Importing auth and logger...');
36
import { BUCKET_NAME, s3Client } from '@/app/s3';
47
import { auth } from '@/utils/auth';
58
import { logger } from '@/utils/logger';
6-
7-
// This log will run as soon as the module is loaded.
8-
logger.info('[uploadFile] Module loaded.');
9-
109
import { GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3';
1110
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
1211
import { AttachmentEntityType, AttachmentType, db } from '@db';
1312
import { revalidatePath } from 'next/cache';
1413
import { headers } from 'next/headers';
1514
import { z } from 'zod';
1615

16+
console.log('[uploadFile] Importing S3 client...');
17+
18+
console.log('[uploadFile] Importing AWS SDK...');
19+
20+
console.log('[uploadFile] Importing database...');
21+
22+
console.log('[uploadFile] All imports successful');
23+
24+
// This log will run as soon as the module is loaded.
25+
logger.info('[uploadFile] Module loaded.');
26+
1727
function mapFileTypeToAttachmentType(fileType: string): AttachmentType {
1828
const type = fileType.split('/')[0];
1929
switch (type) {

apps/app/src/app/s3.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
22

3+
console.log('[S3] S3 module is being loaded...');
4+
35
const APP_AWS_REGION = process.env.APP_AWS_REGION;
46
const APP_AWS_ACCESS_KEY_ID = process.env.APP_AWS_ACCESS_KEY_ID;
57
const APP_AWS_SECRET_ACCESS_KEY = process.env.APP_AWS_SECRET_ACCESS_KEY;

apps/app/src/utils/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const auth = betterAuth({
4545
database: prismaAdapter(db, {
4646
provider: 'postgresql',
4747
}),
48+
baseURL: process.env.BETTER_AUTH_URL,
4849
trustedOrigins: [
4950
'http://localhost:3000',
5051
'https://app.trycomp.ai',

0 commit comments

Comments
 (0)