forked from rucio/webui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
180 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import DIDGatewayOutputPort from "@/lib/core/port/secondary/did-gateway-output-port"; | ||
import { ListDIDsError, ListDIDsRequest, ListDIDsResponse } from "@/lib/core/usecase-models/list-dids-usecase-models"; | ||
import { ListDIDsControllerParameters } from "@/lib/infrastructure/controller/list-dids-controller"; | ||
import { ListDIDsViewModel } from "@/lib/infrastructure/data/view-model/list-did"; | ||
import { BaseStreamableFeature, IOCSymbols } from "@/lib/sdk/ioc-helpers"; | ||
import GATEWAYS from "@/lib/infrastructure/ioc/ioc-symbols-gateway"; | ||
import CONTROLLERS from "@/lib/infrastructure/ioc/ioc-symbols-controllers"; | ||
import INPUT_PORT from "@/lib/infrastructure/ioc/ioc-symbols-input-port"; | ||
import USECASE_FACTORY from "@/lib/infrastructure/ioc/ioc-symbols-usecase-factory"; | ||
import { Container } from "inversify"; | ||
import ListDIDsController from "@/lib/infrastructure/controller/list-dids-controller"; | ||
import ListDIDsUseCase from "@/lib/core/use-case/list-dids-usecase"; | ||
import ListDIDsPresenter from "../../presenter/list-dids-presenter"; | ||
|
||
|
||
export default class ListDidsFeature extends BaseStreamableFeature< | ||
ListDIDsControllerParameters, | ||
ListDIDsRequest, | ||
ListDIDsResponse, | ||
ListDIDsError, | ||
ListDIDsViewModel> { | ||
constructor( appContainer: Container ) { | ||
const didGateway = appContainer.get<DIDGatewayOutputPort>(GATEWAYS.DID) | ||
const symbols: IOCSymbols = { | ||
CONTROLLER: CONTROLLERS.LIST_DIDS, | ||
USECASE_FACTORY: USECASE_FACTORY.LIST_DIDS, | ||
INPUT_PORT: INPUT_PORT.LIST_DIDS, | ||
} | ||
super( | ||
appContainer, | ||
ListDIDsController, | ||
ListDIDsUseCase, | ||
[ | ||
didGateway, | ||
], | ||
ListDIDsPresenter, | ||
false, | ||
symbols | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import appContainer from "@/lib/infrastructure/ioc/container-config"; | ||
import CONTROLLERS from "@/lib/infrastructure/ioc/ioc-symbols-controllers"; | ||
import { BaseController } from "@/lib/sdk/controller"; | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
import { ListDIDsControllerParameters } from "@/lib/infrastructure/controller/list-dids-controller"; | ||
import { withAuthenticatedSessionRoute } from "@/lib/infrastructure/auth/session-utils"; | ||
|
||
async function listDIDs(req: NextApiRequest, res: NextApiResponse, rucioAuthToken: string) { | ||
if(req.method === 'GET') { | ||
res.status(405).json({ error: 'Method Not Allowed' }) | ||
return | ||
} | ||
const { query, type } = req.body | ||
if(!query) { | ||
res.status(400).json({ error: 'Missing query parameter' }) | ||
return | ||
} | ||
if(!type) { | ||
res.status(400).json({ error: 'Missing type parameter' }) | ||
return | ||
} | ||
|
||
const controller = appContainer.get<BaseController<ListDIDsControllerParameters, void>>(CONTROLLERS.LIST_DIDS) | ||
const controllerParameters: ListDIDsControllerParameters = { | ||
response: res, | ||
query: query, | ||
type: type, | ||
rucioAuthToken: rucioAuthToken | ||
} | ||
|
||
await controller.execute(controllerParameters) | ||
} | ||
|
||
export default withAuthenticatedSessionRoute(listDIDs) |