diff --git a/src/lib/infrastructure/ioc/ioc-symbols-input-port.ts b/src/lib/infrastructure/ioc/ioc-symbols-input-port.ts index b2bd651be..e76c206dc 100644 --- a/src/lib/infrastructure/ioc/ioc-symbols-input-port.ts +++ b/src/lib/infrastructure/ioc/ioc-symbols-input-port.ts @@ -14,35 +14,3 @@ const INPUT_PORT = { } export default INPUT_PORT; - -// import fs from 'fs'; -// import path from 'path'; - - -// // Scan the ports directory for files -// const portFiles = fs.readdirSync(path.join(__dirname, '../../core/port/primary')); - -// interface InputPort { -// [key: string]: symbol; -// } - -// const INPUT_PORT: InputPort = {}; - - -// const getInputPorts = () => { -// // console.log(`Registering input ports...${portFiles.length} found`) -// // for (const file of portFiles) { -// // let refName = '' -// // if (file.includes('-ports.ts')) { -// // refName = file.replace('-ports.ts', '').replaceAll('-', '_').toUpperCase(); -// // } else if (file.includes('-port.ts')) { -// // refName = file.replace('-input-port.ts', '').replaceAll('-', '_').toUpperCase(); -// // } -// // const symbolName = `${refName}_INPUT_PORT`; - -// // INPUT_PORT[refName] = Symbol.for(symbolName); -// // console.log(`Registered ${symbolName}`) -// // } -// // return INPUT_PORT; -// } -// export { INPUT_PORT, getInputPorts }; diff --git a/src/lib/sdk/ioc-helpers.ts b/src/lib/sdk/ioc-helpers.ts index a307334db..6e921fe99 100644 --- a/src/lib/sdk/ioc-helpers.ts +++ b/src/lib/sdk/ioc-helpers.ts @@ -120,8 +120,7 @@ TControllerParams extends TParameters, (response: NextApiResponse) => { const presenter = new Presenter(response); return new UseCase(presenter, ...useCaseContructorArgs); - } - ); + }); } } } diff --git a/src/pages/api/auth/login.ts b/src/pages/api/auth/login.ts index d2341c009..7e6cba1b6 100644 --- a/src/pages/api/auth/login.ts +++ b/src/pages/api/auth/login.ts @@ -3,7 +3,8 @@ import { NextApiRequest, NextApiResponse } from "next" import { withSessionRoute } from "@/lib/infrastructure/auth/session-utils" import appContainer from "@/lib/infrastructure/ioc/container-config" import CONTROLLERS from "@/lib/infrastructure/ioc/ioc-symbols-controllers" -import { ILoginConfigController } from "@/lib/infrastructure/controller/login-config-controller" +import { BaseController } from "@/lib/sdk/controller" +import LoginConfigController, { LoginConfigControllerParams } from "@/lib/infrastructure/controller/login-config-controller" async function loginRoute(req: NextApiRequest, res: NextApiResponse) { const sessionExists = req.session !== undefined @@ -25,8 +26,11 @@ async function loginRoute(req: NextApiRequest, res: NextApiResponse) { res.redirect(`/auth/login?callbackUrl=${callbackUrl}`) } else if (req.method === 'POST') { - const loginConfigController = appContainer.get(CONTROLLERS.LOGIN_CONFIG) - await loginConfigController.getLoginViewModel(req.session, res) + const loginConfigController: LoginConfigController = appContainer.get>(CONTROLLERS.LOGIN_CONFIG) + await loginConfigController.execute({ + session: req.session, + response: res + }) } else { res.status(405).json({ error: 'Method not allowed' }) diff --git a/test/api/auth/login-page-config.test.ts b/test/api/auth/login-page-config.test.ts index 00f67f06e..980913d88 100644 --- a/test/api/auth/login-page-config.test.ts +++ b/test/api/auth/login-page-config.test.ts @@ -84,8 +84,11 @@ describe('Login Page Config API Test', () => { process.env['VO_VO2_NAME'] = 'vo2' - const loginConfigController = appContainer.get(CONTROLLERS.LOGIN_CONFIG) - await loginConfigController.getLoginViewModel(session, res); + const loginConfigController = appContainer.get>(CONTROLLERS.LOGIN_CONFIG) + await loginConfigController.execute({ + session: session, + response: res as any, + }); expect(res._getStatusCode()).toBe(200); const viewModel: LoginViewModel = JSON.parse(res._getData()); @@ -133,8 +136,11 @@ describe('Login Page Config API Test', () => { delete process.env['OIDC_PROVIDERS'] - const loginConfigController = appContainer.get(CONTROLLERS.LOGIN_CONFIG) - await loginConfigController.getLoginViewModel(session, res); + const loginConfigController = appContainer.get>(CONTROLLERS.LOGIN_CONFIG) + await loginConfigController.execute({ + session: session, + response: res as any, + }); expect(res._getStatusCode()).toBe(500); const viewModel: LoginViewModel = JSON.parse(res._getData());