Skip to content

Commit 7f683ad

Browse files
committed
Merge branch 'main' of https://github.com/trycompai/comp into claudio/fix-portal
2 parents 406ac49 + 2775fa8 commit 7f683ad

File tree

78 files changed

+4221
-3273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4221
-3273
lines changed

apps/api/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ pids
5454

5555
# Diagnostic reports (https://nodejs.org/api/report.html)
5656
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
57+
58+
59+
prisma/schema.prisma

apps/api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
2929
CMD wget --no-verbose --tries=1 --spider http://localhost:3333/v1/health || exit 1
3030

3131
# Start the application
32-
CMD ["node", "main.js"]
32+
CMD ["node", "src/main.js"]

apps/api/buildspec.yml

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,50 @@ phases:
2626
- '[ -n "$DATABASE_URL" ] || { echo "❌ DATABASE_URL is not set"; exit 1; }'
2727
- '[ -n "$BASE_URL" ] || { echo "❌ BASE_URL is not set"; exit 1; }'
2828

29-
# Install dependencies
30-
- echo "Installing dependencies..."
31-
- bun install --frozen-lockfile
32-
33-
# Generate Prisma client
34-
- echo "Generating Prisma client..."
35-
- cd packages/db && bun x prisma generate && cd ../../
29+
# Install only API workspace dependencies
30+
- echo "Installing API dependencies only..."
31+
- bun install --filter=@comp/api --frozen-lockfile
3632

37-
# Build NestJS application
33+
# Build NestJS application (prebuild automatically handles Prisma)
3834
- echo "Building NestJS application..."
39-
- cd apps/$APP_NAME && bun run build && cd ../../
35+
- echo "APP_NAME is set to $APP_NAME"
36+
- echo "Current directory $(pwd)"
37+
- echo "Available apps $(ls -la apps/)"
38+
- cd apps/api
39+
- echo "Changed to $(pwd)"
40+
- echo "Running build (includes automatic prebuild db:generate)..."
41+
- bun run build
42+
43+
# Verify build output exists
44+
- echo "Checking build output..."
45+
- ls -la dist/
46+
- ls -la dist/src/
47+
- '[ -f "dist/src/main.js" ] || { echo "❌ main.js not found in dist/src"; exit 1; }'
4048

41-
# Create self-contained bundle for Docker
49+
# Create self-contained bundle for Docker (stay in apps/api)
4250
- echo "Creating self-contained bundle..."
43-
- cd apps/$APP_NAME
4451
- mkdir -p ../docker-build
4552

46-
# Copy built application
53+
# Copy built application (preserves NestJS structure)
54+
- echo "Copying built application..."
4755
- cp -r dist/* ../docker-build/
4856

49-
# Copy entire node_modules for runtime (simpler and comprehensive)
57+
# Copy prisma folder (needed for runtime imports)
58+
- echo "Copying prisma folder..."
59+
- cp -r prisma ../docker-build/
60+
61+
# Verify files were copied correctly
62+
- echo "Verifying copied files..."
63+
- ls -la ../docker-build/
64+
- ls -la ../docker-build/src/
65+
- '[ -f "../docker-build/src/main.js" ] || { echo "❌ main.js not found in docker-build/src"; exit 1; }'
66+
67+
# Copy entire node_modules for runtime (includes @trycompai/db from npm)
5068
- echo "Bundling all runtime dependencies..."
5169
- cp -r ../../node_modules ../docker-build/
5270

53-
# Copy @trycompai/db package
54-
- mkdir -p ../docker-build/node_modules/@trycompai
55-
- cp -r ../../packages/db ../docker-build/node_modules/@trycompai/
56-
5771
# Copy Dockerfile
72+
- echo "Copying Dockerfile..."
5873
- cp Dockerfile ../docker-build/
5974

6075
# Build Docker image
@@ -69,7 +84,7 @@ phases:
6984
- docker push $ECR_REPOSITORY_URI:latest
7085
- echo "Updating ECS service..."
7186
- aws ecs update-service --cluster $ECS_CLUSTER_NAME --service $ECS_SERVICE_NAME --force-new-deployment
72-
- 'printf "[{\"name\":\"%s-container\",\"imageUri\":\"%s\"}]" $APP_NAME $ECR_REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json'
87+
- 'printf "[{\"name\":\"%s-container\",\"imageUri\":\"%s\"}]" api $ECR_REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json'
7388

7489
cache:
7590
paths:

apps/api/eslint.config.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ export default tseslint.config(
2828
rules: {
2929
'@typescript-eslint/no-explicit-any': 'off',
3030
'@typescript-eslint/no-floating-promises': 'warn',
31-
'@typescript-eslint/no-unsafe-argument': 'warn'
31+
'@typescript-eslint/no-unsafe-argument': 'warn',
32+
'@typescript-eslint/no-unsafe-assignment': 'off',
33+
'@typescript-eslint/no-unsafe-call': 'off',
34+
'@typescript-eslint/no-unsafe-member-access': 'off',
35+
'@typescript-eslint/no-unsafe-return': 'off',
36+
'@typescript-eslint/restrict-template-expressions': 'off',
3237
},
3338
},
34-
);
39+
);

apps/api/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,24 @@
1818
"test:watch": "jest --watch",
1919
"test:cov": "jest --coverage",
2020
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
21-
"test:e2e": "jest --config ./test/jest-e2e.json"
21+
"test:e2e": "jest --config ./test/jest-e2e.json",
22+
"typecheck": "tsc --noEmit",
23+
"db:generate": "bun run db:getschema && prisma generate",
24+
"db:getschema": "cp ../../node_modules/@trycompai/db/dist/schema.prisma prisma/schema.prisma",
25+
"prebuild": "bun run db:generate"
2226
},
2327
"dependencies": {
28+
"@aws-sdk/client-s3": "^3.859.0",
29+
"@aws-sdk/s3-request-presigner": "^3.859.0",
2430
"@nestjs/common": "^11.0.1",
31+
"@nestjs/config": "^4.0.2",
2532
"@nestjs/core": "^11.0.1",
2633
"@nestjs/platform-express": "^11.1.5",
2734
"@nestjs/swagger": "^11.2.0",
28-
"@trycompai/db": "file:../../packages/db",
35+
"@trycompai/db": "^1.3.2",
2936
"class-transformer": "^0.5.1",
3037
"class-validator": "^0.14.2",
38+
"jose": "^6.0.12",
3139
"reflect-metadata": "^0.2.2",
3240
"rxjs": "^7.8.1",
3341
"swagger-ui-express": "^5.0.1",

apps/api/prisma/client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { PrismaClient } from '@prisma/client';
2+
3+
const globalForPrisma = global as unknown as { prisma: PrismaClient };
4+
5+
export const db = globalForPrisma.prisma || new PrismaClient();
6+
7+
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = db;

apps/api/prisma/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from '@prisma/client';
2+
export { db } from './client';

apps/api/src/app.module.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
import { Module } from '@nestjs/common';
2+
import { ConfigModule } from '@nestjs/config';
23
import { AppController } from './app.controller';
34
import { AppService } from './app.service';
5+
import { AttachmentsModule } from './attachments/attachments.module';
46
import { AuthModule } from './auth/auth.module';
7+
import { CommentsModule } from './comments/comments.module';
8+
import { awsConfig } from './config/aws.config';
59
import { HealthModule } from './health/health.module';
610
import { OrganizationModule } from './organization/organization.module';
711
import { TasksModule } from './tasks/tasks.module';
812

913
@Module({
10-
imports: [AuthModule, OrganizationModule, TasksModule, HealthModule],
14+
imports: [
15+
ConfigModule.forRoot({
16+
isGlobal: true,
17+
load: [awsConfig],
18+
validationOptions: {
19+
allowUnknown: true,
20+
abortEarly: true,
21+
},
22+
}),
23+
AuthModule,
24+
OrganizationModule,
25+
AttachmentsModule,
26+
TasksModule,
27+
CommentsModule,
28+
HealthModule,
29+
],
1130
controllers: [AppController],
1231
providers: [AppService],
1332
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Module } from '@nestjs/common';
2+
import { AttachmentsService } from './attachments.service';
3+
4+
@Module({
5+
providers: [AttachmentsService],
6+
exports: [AttachmentsService],
7+
})
8+
export class AttachmentsModule {}

0 commit comments

Comments
 (0)