Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy-nest-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deployment Nestjs server (Dev)

on:
push:
branches: [development]
branches: [development-disabled-temporarily]

jobs:
build-and-deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-nest-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deployment Nestjs server (Prod)

on:
push:
branches: [main]
branches: [main-disabled-temporarily]

jobs:
build-and-deploy:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ node_modules/
.tanstack
*.pem
*.key
*.crt
*.crt
robots.txt
sitemap.xml
Comment on lines +19 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

robots.txt and sitemap.xml are generally not included in .gitignore as they are crucial for search engine optimization (SEO). If these files are generated during the build process and are meant to be publicly accessible, they should be committed or be part of the build output that gets deployed. Ignoring them might prevent search engine crawlers from finding and indexing your site correctly. Please verify if ignoring these files is the intended behavior.

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
InterviewAnswerForm as InterviewAnswerFormType
} from "@kokomen/types";
import { useSpeechRecognitionWithEvents } from "@/domains/interview/hooks/useSpeechRecognitionWithEvents";
import { interviewEventHelpers } from "@/domains/interview/utils/interviewEventEmitter";
import type { InterviewerEmotion } from "@/pages/interviews/[interviewId]";
import { captureFormSubmitEvent } from "@/utils/analytics";
import { Button, LoadingCircles, Textarea } from "@kokomen/ui";
import { getEmotion } from "@kokomen/utils";
import { useMutation } from "@tanstack/react-query";
import { ArrowBigUp, CircleStop, Mic } from "lucide-react";
import React, { JSX, MouseEvent, useCallback, useRef, useState } from "react";
import { publishInterviewEvent } from "@/domains/interview/utils/interviewEventEmitter";

type InterviewInputProps = Pick<
Interview,
Expand Down Expand Up @@ -85,7 +85,7 @@ export function InterviewAnswerForm({
);
},
onMutate: (data) => {
interviewEventHelpers.stopVoiceRecognition();
publishInterviewEvent("stopVoiceRecognition");
captureFormSubmitEvent({
name: "submitInterviewAnswer",
properties: {
Expand Down Expand Up @@ -294,7 +294,7 @@ function VoiceInputButton({
name="interview-voice-stop"
variant={"glass"}
className="flex items-center gap-2 text-text-tertiary"
onClick={interviewEventHelpers.stopVoiceRecognition}
onClick={() => publishInterviewEvent("stopVoiceRecognition")}
disabled={disabled}
>
<CircleStop
Expand All @@ -313,7 +313,7 @@ function VoiceInputButton({
name="interview-voice-start"
variant={"glass"}
className="flex items-center gap-2 text-text-tertiary"
onClick={interviewEventHelpers.startVoiceRecognition}
onClick={() => publishInterviewEvent("startVoiceRecognition")}
disabled={disabled}
>
<Mic className={`${isVoiceListening ? "animate-pulse" : ""}`} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useRef, useState } from "react";
import {
useInterviewEvent,
interviewEventHelpers
publishInterviewEvent
} from "@/domains/interview/utils/interviewEventEmitter";
import { InterviewMode } from "@kokomen/types";

Expand Down Expand Up @@ -57,20 +57,20 @@ export const useSpeechRecognitionWithEvents = ({
const handleSpeechStart = useCallback((): void => {
setIsListening(true);
setError(null);
interviewEventHelpers.notifyVoiceStarted();
publishInterviewEvent("interview:voiceRecognitionStarted");
}, []);

const handleSpeechEnd = useCallback((): void => {
setIsListening(false);
interviewEventHelpers.notifyVoiceStopped();
publishInterviewEvent("interview:voiceRecognitionStopped");

if (result.current[resultPointer.current] === "") {
return;
}
if (mode === "VOICE") {
interviewEventHelpers.stopVoiceRecognition();
publishInterviewEvent("interview:stopVoiceRecognition");
setTimeout(() => {
interviewEventHelpers.startVoiceRecognition();
publishInterviewEvent("interview:startVoiceRecognition");
}, 500);
}
resultPointer.current++;
Expand All @@ -89,7 +89,9 @@ export const useSpeechRecognitionWithEvents = ({
result.current[resultPointer.current] = resultString;
const fullResult = result.current.join(" ");
onSpeechEnd(fullResult);
interviewEventHelpers.sendVoiceResult(fullResult);
publishInterviewEvent("interview:voiceRecognitionResult", {
text: fullResult
});
},
[onSpeechEnd, enabled]
);
Expand Down Expand Up @@ -122,11 +124,13 @@ export const useSpeechRecognitionWithEvents = ({
}
setError(errorMessage);

interviewEventHelpers.notifyVoiceError(errorMessage);
publishInterviewEvent("interview:voiceRecognitionError", {
error: errorMessage
});
if (mode === "VOICE") {
interviewEventHelpers.stopVoiceRecognition();
publishInterviewEvent("interview:stopVoiceRecognition");
setTimeout(() => {
interviewEventHelpers.startVoiceRecognition();
publishInterviewEvent("interview:startVoiceRecognition");
}, 2000);
}
setTimeout(() => {
Expand Down Expand Up @@ -187,7 +191,9 @@ export const useSpeechRecognitionWithEvents = ({
if (!isSupported) {
const errorMsg = "음성 인식이 지원되지 않습니다.";
setError(errorMsg);
interviewEventHelpers.notifyVoiceError(errorMsg);
publishInterviewEvent("interview:voiceRecognitionError", {
error: errorMsg
});
return;
}

Expand All @@ -204,7 +210,9 @@ export const useSpeechRecognitionWithEvents = ({
} catch (error) {
const errorMsg = "음성 인식을 시작할 수 없습니다.";
setError(errorMsg);
interviewEventHelpers.notifyVoiceError(errorMsg);
publishInterviewEvent("interview:voiceRecognitionError", {
error: errorMsg
});
}
}, [isSupported, createSpeechRecognition, detachEventListeners]);

Expand All @@ -226,7 +234,7 @@ export const useSpeechRecognitionWithEvents = ({

// 이벤트 구독 - 음성 인식 시작 요청
useInterviewEvent(
"startVoiceRecognition",
"interview:startVoiceRecognition",
() => {
startListening();
},
Expand All @@ -235,7 +243,7 @@ export const useSpeechRecognitionWithEvents = ({

// 이벤트 구독 - 음성 인식 중지 요청
useInterviewEvent(
"stopVoiceRecognition",
"interview:stopVoiceRecognition",
() => {
stopListening();
},
Expand All @@ -251,7 +259,9 @@ export const useSpeechRecognitionWithEvents = ({
setIsSupported(false);
const errorMsg = "이 브라우저는 음성 인식을 지원하지 않습니다.";
setError(errorMsg);
interviewEventHelpers.notifyVoiceError(errorMsg);
publishInterviewEvent("interview:voiceRecognitionError", {
error: errorMsg
});
return;
}

Expand Down
115 changes: 12 additions & 103 deletions apps/client/src/domains/interview/utils/interviewEventEmitter.ts
Original file line number Diff line number Diff line change
@@ -1,113 +1,22 @@
/* eslint-disable no-unused-vars */
import { EventEmitter } from "events";
import { DependencyList, useEffect } from "react";

export type InterviewEventType =
| "startVoiceRecognition"
| "stopVoiceRecognition"
| "voiceRecognitionStarted"
| "voiceRecognitionStopped"
| "voiceRecognitionError"
| "voiceRecognitionResult";

interface InterviewEventPayloads {
startVoiceRecognition: undefined;
stopVoiceRecognition: undefined;
voiceRecognitionStarted: undefined;
voiceRecognitionStopped: undefined;
voiceRecognitionError: { error: string };
voiceRecognitionResult: { text: string };
}

class TypedEventEmitter extends EventEmitter {
public emit<K extends InterviewEventType>(
event: K,
...args: InterviewEventPayloads[K] extends undefined
? []
: [InterviewEventPayloads[K]]
): boolean {
return super.emit(event, ...args);
}

public on<K extends InterviewEventType>(
event: K,
listener: InterviewEventPayloads[K] extends undefined
? () => void
: (payload: InterviewEventPayloads[K]) => void
): this {
return super.on(event, listener);
}

public off<K extends InterviewEventType>(
event: K,
listener: InterviewEventPayloads[K] extends undefined
? () => void
: (payload: InterviewEventPayloads[K]) => void
): this {
return super.off(event, listener);
}

public once<K extends InterviewEventType>(
event: K,
listener: InterviewEventPayloads[K] extends undefined
? () => void
: (payload: InterviewEventPayloads[K]) => void
): this {
return super.once(event, listener);
}
}

// 싱글톤 인스턴스
export const interviewEvents: TypedEventEmitter = new TypedEventEmitter();

// React Hook for subscribing to events
import { publishEvent, useSubscribeEvents } from "@/utils/eventEmitter";
import { InterviewEventPayloads, InterviewEventType } from "@kokomen/types";
import { DependencyList } from "react";
// 이벤트에 대서 콜백 함수 구독하는 훅
export function useInterviewEvent<K extends InterviewEventType>(
event: K,
handler: InterviewEventPayloads[K] extends undefined
? () => void
: (payload: InterviewEventPayloads[K]) => void,
deps: DependencyList = []
): void {
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
interviewEvents.on(event, handler as any);
return () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
interviewEvents.off(event, handler as any);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [event, ...deps]);
const eventEmitter = useSubscribeEvents<InterviewEventType>(
[{ event, handler }],
[]
);
Comment on lines +13 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The deps argument from useInterviewEvent is not being passed down to useSubscribeEvents. It's hardcoded as an empty array []. This will cause the event handler to have stale closures if it depends on any props or state that change over time, as the useEffect in useSubscribeEvents will not re-run to subscribe the new handler with the updated dependencies.

Suggested change
const eventEmitter = useSubscribeEvents<InterviewEventType>(
[{ event, handler }],
[]
);
const eventEmitter = useSubscribeEvents<InterviewEventType>(
[{ event, handler }],
deps
);

}

// 이벤트 발행 헬퍼 함수들
export const interviewEventHelpers: {
startVoiceRecognition: () => void;
stopVoiceRecognition: () => void;
notifyVoiceStarted: () => void;
notifyVoiceStopped: () => void;
notifyVoiceError: (error: string) => void;
sendVoiceResult: (text: string) => void;
} = {
startVoiceRecognition: (): void => {
interviewEvents.emit("startVoiceRecognition");
},
stopVoiceRecognition: (): void => {
interviewEvents.emit("stopVoiceRecognition");
},

notifyVoiceStarted: (): void => {
interviewEvents.emit("voiceRecognitionStarted");
},

notifyVoiceStopped: (): void => {
interviewEvents.emit("voiceRecognitionStopped");
},

notifyVoiceError: (error: string): void => {
interviewEvents.emit("voiceRecognitionError", { error });
},

sendVoiceResult: (text: string): void => {
interviewEvents.emit("voiceRecognitionResult", { text });
}
};
export const publishInterviewEvent = publishEvent<
InterviewEventType,
InterviewEventPayloads
>();
21 changes: 21 additions & 0 deletions apps/client/src/domains/resume/api/archive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { mapToCamelCase } from "@/utils/convertConvention";
import { ArchivedResumeAndPortfolio } from "@kokomen/types";
import axios from "axios";

const archiveServerInstance = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL + "/resumes",
withCredentials: true
});

export const getArchivedResumes = (type?: "ALL" | "RESUME" | "PORTFOLIO") => {
return archiveServerInstance
.get<{
resumes: ArchivedResumeAndPortfolio[];
portfolios: ArchivedResumeAndPortfolio[];
}>("", {
params: {
type: type ?? "ALL"
}
})
.then((res) => mapToCamelCase(res.data));
};
Loading