Skip to content

Commit

Permalink
refactor: 조건부 로직 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
ppinkypeach committed Feb 11, 2024
1 parent eaaa7d4 commit 38b77d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions server/types/AwsEvent.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AwsEvent, AwsCallback, AwsResponse } from "@slack/bolt/dist/receivers/AwsLambdaReceiver";

interface CustomAwsEvent extends AwsEvent {
source?: string;
}
8 changes: 7 additions & 1 deletion server/utils/function/lambdaHandler/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ import { submitNotionCommandHandler } from "../../../notion/blog/handler/submitN
import { uploadNotionBlogViewHandler } from "../../../notion/blog/handler/uploadNotionBlogViewHandler";
import { app } from "../../appModule/slack/slack";
import { notion } from "../../appModule/notion/notion";
import { CustomAwsEvent } from "../../../types/AwsEvent";

let handlerRegistered = false;

export const handler = async(
event: AwsEvent,
event: CustomAwsEvent,
context: any,
callback: AwsCallback
): Promise<AwsResponse> => {
if(event.source === 'aws.events'){
console.log('Warm Start 설정');
return {statusCode:200, body:'Warm Start 완료'};
}

if(!handlerRegistered){
submitNotionCommandHandler(app);
uploadNotionBlogViewHandler(app, notion);
Expand Down

0 comments on commit 38b77d1

Please sign in to comment.