'use strict';
const httpStatus = require('http-status');
const generateControllers = require('../../core/controllers');
const { buildContext } = require('../../core/controllers');
const { extractParamsFromRequest, handleErrorResponse, handleResultResponse } = require('../../helpers/controller.helper');
const multimediaService = require('./multimedia.service');
const multimediaFileService = require('./multimedia_file.service');
const cdnHelper = require('../../helpers/cdn.helper');

// Module Name
const MODULE_NAME = '[multimedia.controller]';

const controllerOptions = { MODULE_NAME };
const extraControllers = {

    create: (config) => {
        return async (req, res, next) => {
            try {
                var file = req.file;
                var data = req.body;

                const context = buildContext(req, config);
                console.log(data, context);
                
                const result = await multimediaService.create(data, context);
                return handleResultResponse(result, null, null, res, httpStatus.CREATED)
            } catch (error) {
                return handleErrorResponse(MODULE_NAME, 'create', error, res)
            }
        }
    },    
};

module.exports = generateControllers(multimediaService, extraControllers, controllerOptions);

