"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const routing_controllers_1 = require("@gem-mine/routing-controllers");
const db_1 = require("../db");
let default_1 = class default_1 {
    getList({ template_id, }) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            return {
                data: [
                    yield db_1.db.get('template')
                        .find({
                        template_id
                    }).value()
                ].filter(Boolean)
            };
        });
    }
    createOne(modal) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            const data = {
                template_id: modal.template_id,
                token: modal.token
            };
            yield db_1.db.get('template')
                .updateOrAdd(data, 'template_id')
                .write();
            return {
                data
            };
        });
    }
};
tslib_1.__decorate([
    routing_controllers_1.Get('/'),
    tslib_1.__param(0, routing_controllers_1.QueryParams()),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [Object]),
    tslib_1.__metadata("design:returntype", Promise)
], default_1.prototype, "getList", null);
tslib_1.__decorate([
    routing_controllers_1.Post('/'),
    tslib_1.__param(0, routing_controllers_1.Body()),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [Object]),
    tslib_1.__metadata("design:returntype", Promise)
], default_1.prototype, "createOne", null);
default_1 = tslib_1.__decorate([
    routing_controllers_1.Controller('/template')
], default_1);
exports.default = default_1;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVtcGxhdGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJvbGxlci90ZW1wbGF0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx1RUFBd0Y7QUFDeEYsOEJBQTBCO0FBRzFCLGdCQUFBO0lBRVEsT0FBTyxDQUFnQixFQUMzQixXQUFXLEdBR1o7O1lBQ0MsT0FBTztnQkFDTCxJQUFJLEVBQUU7b0JBQ0osTUFBTSxPQUFFLENBQUMsR0FBRyxDQUFDLFVBQVUsQ0FBQzt5QkF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