Tools for learning Japanese.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
760 B

  1. import {RouteHandlerMethod} from 'fastify';
  2. import {CreateDownloaderParams} from '@modal-sh/murasaki-core';
  3. import {InitService, InitServiceImpl} from './InitService';
  4. import {constants} from 'http2';
  5. export interface InitController {
  6. downloadDataset: RouteHandlerMethod;
  7. }
  8. export class InitControllerImpl implements InitController {
  9. constructor(private readonly initService: InitService = new InitServiceImpl()) {
  10. // noop
  11. }
  12. readonly downloadDataset: RouteHandlerMethod = async (request, reply) => {
  13. try {
  14. const result = await this.initService.downloadDataset(request.body as CreateDownloaderParams);
  15. reply.send(result);
  16. } catch (err) {
  17. reply.status(constants.HTTP_STATUS_INTERNAL_SERVER_ERROR).send(err);
  18. }
  19. };
  20. }