Skip to content

Commit

Permalink
feat: call ai lambda function invoke at create post
Browse files Browse the repository at this point in the history
  • Loading branch information
JonghunAn committed Jun 29, 2024
1 parent bf974bc commit b6b54d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/modules/posts/posts.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import { PostsRepository } from '@src/modules/posts/posts.repository';
import { MongooseModule } from '@nestjs/mongoose';
import { Post, PostSchema } from '@src/infrastructure';
import { UsersModule } from '@src/modules/users/users.module';
import { AwsLambdaModule } from '@src/infrastructure/aws-lambda/aws-lambda.module';
import { AwsLambdaService } from '@src/infrastructure/aws-lambda/aws-lambda.service';

@Module({
imports: [
MongooseModule.forFeature([{ name: Post.name, schema: PostSchema }]),
UsersModule,
AwsLambdaModule,
],
controllers: [PostsController],
providers: [PostsService, PostsRepository],
providers: [PostsService, PostsRepository, AwsLambdaService],
})
export class PostsModule {}
14 changes: 13 additions & 1 deletion src/modules/posts/posts.service.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import { Injectable } from '@nestjs/common';
import { CreatePostDto } from '@src/modules/posts/dto/create-post.dto';
import { PostsRepository } from '@src/modules/posts/posts.repository';
import { AwsLambdaService } from '@src/infrastructure/aws-lambda/aws-lambda.service';

@Injectable()
export class PostsService {
constructor(private readonly postRepository: PostsRepository) {}
constructor(
private readonly awsLambdaService: AwsLambdaService,
private readonly postRepository: PostsRepository,
) {}
async createPost(
createPostDto: CreatePostDto,
userId: string,
): Promise<boolean> {
// TODO get title from url
const title: string = 'temp title';

// TODO lambda function name
// const ai_lambda_function_name = 'ai_lambda_function_name';
// const payload = {
// postContent: 'contents',
// folderList: ['dummy_folder_list'],
// };
// this.awsLambdaService.invoke_lambda(ai_lambda_function_name, payload);

return await this.postRepository.createPost(
userId,
createPostDto.folderId,
Expand Down

0 comments on commit b6b54d2

Please sign in to comment.