Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/api/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Application Configuration
PORT=8000

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=your_strong_password_here

# Supabase Configuration
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_KEY=your_supabase_service_key_here

RESEND_API_KEY=your_resend_api_key
30 changes: 0 additions & 30 deletions apps/api/env.example

This file was deleted.

14 changes: 13 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dev": "nest start --watch",
"build": "nest build",
"start": "nest start",
"start:worker": "cross-env NODE_ENV=worker nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"test": "jest",
Expand All @@ -16,19 +17,30 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@elevenlabs/elevenlabs-js": "^2.21.0",
"@nestjs/bullmq": "^10.2.1",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^10.0.0",
"@nestjs/jwt": "^11.0.1",
"@nestjs/platform-express": "^10.0.0",
"@repo/api": "workspace:*",
"@repo/email-templates": "workspace:*",
"@repo/queues": "workspace:*",
"@repo/supabase": "workspace:*",
"@repo/validation": "workspace:*",
"@supabase/supabase-js": "^2.53.0",
"@tabler/icons-react": "^3.34.1",
"bullmq": "^5.62.2",
"clsx": "^2.1.1",
"jsonrepair": "^3.13.0",
"motion": "^12.23.12",
"reflect-metadata": "^0.2.0",
"resend": "^4.8.0",
"rxjs": "^7.8.1",
"tailwind-merge": "^2.6.0"
"tailwind-merge": "^2.6.0",
"ytdl-core": "^4.11.5",
"zod": "^3.23.8"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
Expand Down
18 changes: 14 additions & 4 deletions apps/api/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get, Req, UseGuards } from '@nestjs/common';
import { AppService } from './app.service';
import { SupabaseService } from './supabase/supabase.service';
import { SupabaseAuthGuard } from './guards/auth.guard';

@Controller()
@UseGuards(SupabaseAuthGuard)
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(private readonly appService: AppService, private readonly supabaseService: SupabaseService) { }

@Get()
getHello(): string {
return this.appService.getHello();
getTrainAI() {
return { message: 'Protected train-ai endpoint' };
}

@Get('test-db')
async testDb(@Req() req) {
const { data, error } = await this.supabaseService.getClient().from('profiles').select('*').limit(1);
if (error) throw error;
return data;
}
}
37 changes: 30 additions & 7 deletions apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';

import { LinksModule } from './links/links.module';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { BullModule } from '@nestjs/bullmq';
import { TrainAiProcessor } from '@repo/queues';
import redisConfig from './config/redis.config';
import { SupabaseModule } from './supabase/supabase.module';

import { AppService } from './app.service';
import { AppController } from './app.controller';
import { TrainAiController } from './train-ai/train-ai.controller';
import { TrainAiModule } from './train-ai/train-ai.module';
import { AuthModule } from './auth/auth.module';

@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
load: [redisConfig]
}),
BullModule.forRootAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
connection: configService.get('redis'),
defaultJobOptions: {
attempts: 3,
backoff: { type: 'exponential', delay: 1000 },
removeOnComplete: { count: 1000 },
removeOnFail: { count: 5000 },
limiter: { max: 100, duration: 60000 }
},
}),
inject: [ConfigService],
}),
BullModule.registerQueue({
name: 'train-ai'
}),
SupabaseModule,
LinksModule,
TrainAiModule,
AuthModule
],
controllers: [AppController],
providers: [AppService],
controllers: [AppController, TrainAiController],
providers: [AppService, TrainAiProcessor],
})
export class AppModule {}
export class AppModule { }
38 changes: 38 additions & 0 deletions apps/api/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// src/auth/auth.controller.ts
import { Controller, Post, Body, HttpCode, HttpStatus } from '@nestjs/common';
import { AuthService } from './auth.service';
import { forgotPasswordSchema, resetPasswordSchema, verifyOtpSchema } from '@repo/validation';
import { ZodValidationPipe } from '../common/pipes/zod-validation.pipe';
import type { z } from 'zod';

@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) { }

@Post('forgot-password')
@HttpCode(HttpStatus.OK)
async forgotPassword(
@Body(new ZodValidationPipe(forgotPasswordSchema))
body: z.infer<typeof forgotPasswordSchema>,
) {
return this.authService.forgotPassword(body.email);
}

@Post('verify-otp')
@HttpCode(HttpStatus.OK)
async verifyOtp(
@Body(new ZodValidationPipe(verifyOtpSchema))
body: z.infer<typeof verifyOtpSchema>,
) {
return this.authService.verifyOtp(body.email, body.otp);
}

@Post('reset-password')
@HttpCode(HttpStatus.OK)
async resetPassword(
@Body(new ZodValidationPipe(resetPasswordSchema))
body: z.infer<typeof resetPasswordSchema>,
) {
return this.authService.resetPassword(body.email, body.otp, body.newPassword, body.confirmNewPassword);
}
}
11 changes: 11 additions & 0 deletions apps/api/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
import { SupabaseModule } from '../supabase/supabase.module';

@Module({
imports: [SupabaseModule],
controllers: [AuthController],
providers: [AuthService],
})
export class AuthModule {}
Loading
Loading