|
- import {RouteHandlerMethod} from 'fastify';
- import {CreateDownloaderParams} from '@modal-sh/murasaki-core';
- import {InitService, InitServiceImpl} from './InitService';
- import {constants} from 'http2';
-
- export interface InitController {
- downloadDataset: RouteHandlerMethod;
- }
-
- export class InitControllerImpl implements InitController {
- constructor(private readonly initService: InitService = new InitServiceImpl()) {
- // noop
- }
-
- readonly downloadDataset: RouteHandlerMethod = async (request, reply) => {
- try {
- const result = await this.initService.downloadDataset(request.body as CreateDownloaderParams);
- reply.send(result);
- } catch (err) {
- reply.status(constants.HTTP_STATUS_INTERNAL_SERVER_ERROR).send(err);
- }
- };
- }
|