Skip to content

Commit db754c6

Browse files
authored
Merge pull request #1200 from trycompai/main
[comp] Production Deploy
2 parents ceda35c + 65d227e commit db754c6

5 files changed

Lines changed: 32 additions & 7 deletions

File tree

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

Lines changed: 20 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) {
@@ -40,7 +50,10 @@ const uploadAttachmentSchema = z.object({
4050
});
4151

4252
export const uploadFile = async (input: z.infer<typeof uploadAttachmentSchema>) => {
53+
console.log('[uploadFile] Function called - starting execution');
4354
logger.info(`[uploadFile] Starting upload for ${input.fileName}`);
55+
56+
console.log('[uploadFile] Checking S3 client availability');
4457
try {
4558
// Check if S3 client is available
4659
if (!s3Client) {
@@ -59,9 +72,11 @@ export const uploadFile = async (input: z.infer<typeof uploadAttachmentSchema>)
5972
} as const;
6073
}
6174

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

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

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

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

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

8096
const MAX_FILE_SIZE_MB = 10;

apps/app/src/app/(app)/[orgId]/tasks/[taskId]/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ export default async function TaskPage({
1313
}: {
1414
params: Promise<{ taskId: string; orgId: string; locale: string }>;
1515
}) {
16+
console.log('[TaskPage] Starting page render');
1617
const { taskId, orgId } = await params;
18+
console.log('[TaskPage] Params extracted:', { taskId, orgId });
19+
console.log('[TaskPage] Getting session');
1720
const session = await auth.api.getSession({
1821
headers: headers(),
1922
});
23+
console.log('[TaskPage] Session obtained, fetching data');
2024

2125
const [task, members, comments, attachments] = await Promise.all([
2226
getTask(taskId, session),

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/middleware.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ export async function middleware(request: NextRequest) {
110110

111111
const hasAccess = foundOrg?.hasAccess;
112112

113-
console.log(`[MIDDLEWARE] Checking access for org ${orgId}: ${hasAccess}`);
114-
115113
if (!hasAccess) {
116114
const url = new URL(`/upgrade/${orgId}`, request.url);
117115
// Preserve existing search params

apps/app/src/utils/auth.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ export const auth = betterAuth({
4545
database: prismaAdapter(db, {
4646
provider: 'postgresql',
4747
}),
48-
trustedOrigins: ['http://localhost:3000', 'https://app.trycomp.ai', 'https://dev.trycomp.ai'],
48+
baseURL: process.env.BETTER_AUTH_URL,
49+
trustedOrigins: [
50+
'http://localhost:3000',
51+
'https://app.trycomp.ai',
52+
'https://app.staging.trycomp.ai',
53+
],
4954
emailAndPassword: {
5055
enabled: true,
5156
},

0 commit comments

Comments
 (0)