"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const v4_1 = __importDefault(require("uuid/v4"));
const typeorm_1 = require("typeorm");
const entities_1 = require("../../../entities");
const thumbnail_1 = require("../../../controllers/thumbnail");
exports.createBoard = {
    async createBoard(_, { board: attrs, groupId }) {
        const repository = typeorm_1.getRepository(entities_1.Board);
        const newBoard = Object.assign({ id: v4_1.default() }, attrs);
        const groupRepository = typeorm_1.getRepository(entities_1.Group);
        newBoard.group = await groupRepository.findOne({
            id: groupId
        });
        const base64 = await thumbnail_1.thumbnail({
            model: attrs.model
        });
        newBoard.thumbnail = 'data:image/png;base64,' + base64.toString('base64');
        return await repository.save(newBoard);
    }
};
//# sourceMappingURL=create-board.js.map