All files / infra/controller upload-controller.ts

0% Statements 0/33
0% Branches 0/1
0% Functions 0/1
0% Lines 0/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                                                       
import {  Response } from "express";
import { StatusCodes } from "http-status-codes";
import { ExtractDataFileUseCaseFactory } from "../facotry/abstract-factory/invoice/extract-data-file-use-case-factory";
import { connectionPrisma } from "../prisma/prisma";



export const extract = async (req: any, res: Response): Promise<void> => {
  try {
    const extractAbstractFacture = ExtractDataFileUseCaseFactory.ExtractDataFileAbstractFactory(connectionPrisma);
    extractAbstractFacture.execute();
    res.json({ message: 'Dados extraidos com sucesso' })

  } catch (error:any) {
    res.status(StatusCodes.INTERNAL_SERVER_ERROR).json({
      errors: error.message,
    });
  }
};
export const upLoad = async (req: any, res: Response): Promise<void> => {
  try {
    if (!req.file) {
       res.status(StatusCodes.BAD_REQUEST).json({ error: 'No file uploaded' });
    }
  
    res.json({ message: 'File uploaded successfully', filename: req.file.filename })

  } catch (error:any) {
    res.status(StatusCodes.INTERNAL_SERVER_ERROR).json({
      errors: error.message,
    });
  }
};