전체적인 리팩토링
This commit is contained in:
25
app/api/autotrade/sessions/active/route.ts
Normal file
25
app/api/autotrade/sessions/active/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import {
|
||||
AUTOTRADE_API_ERROR_CODE,
|
||||
createAutotradeErrorResponse,
|
||||
getAutotradeSession,
|
||||
getAutotradeUserId,
|
||||
} from "@/app/api/autotrade/_shared";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const userId = await getAutotradeUserId(request.headers);
|
||||
if (!userId) {
|
||||
return createAutotradeErrorResponse({
|
||||
status: 401,
|
||||
code: AUTOTRADE_API_ERROR_CODE.AUTH_REQUIRED,
|
||||
message: "로그인이 필요합니다.",
|
||||
});
|
||||
}
|
||||
|
||||
const session = getAutotradeSession(userId);
|
||||
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
session: session && session.runtimeState === "RUNNING" ? session : null,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user