"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var TestController_1;
Object.defineProperty(exports, "__esModule", { value: true });
"use strict";
const server_1 = require("@methodus/server");
const db_1 = require("../db");
let TestController = TestController_1 = class TestController {
    static list(filter = {}, pageNumber = 1, pageSize = 10, req) {
        return __awaiter(this, void 0, void 0, function* () {
            if (!filter) {
                filter = {};
            }
            const dbResult = db_1.DB.getPosts(filter, pageNumber, pageSize);
            const result = new server_1.MethodResult(dbResult);
            result.linkAction('get', TestController_1, 'Post', dbResult, req.headers['host']);
            return result.apply();
        });
    }
    // result.pipe({});
    // result.on('finish', (data: any) => {
    //     return data;
    // });
    // result.setHeader('good-header', generateUuid());
    static get(id, host = '') {
        return __awaiter(this, void 0, void 0, function* () {
            const dbResult = db_1.DB.getPosts({ id: Number(id) }, 1, 10);
            const result = new server_1.MethodResult(dbResult);
            result.linkAction('list', TestController_1, 'Get', {}, host);
            return result.apply();
        });
    }
    static listdefaults(player_name, body, headers, files, cookies, query, res, req, securityContext) {
        return __awaiter(this, void 0, void 0, function* () {
            return new server_1.MethodResultStatus([1, 2, 3, 4, 5], 203, 5, 1);
        });
    }
    static create(files, cookies, name) {
        return __awaiter(this, void 0, void 0, function* () {
            return new server_1.MethodResult({ name });
        });
    }
    static read(playerId) {
        return __awaiter(this, void 0, void 0, function* () {
            return new server_1.MethodResult(playerId);
        });
    }
    static getByField(field, value) {
        return __awaiter(this, void 0, void 0, function* () {
            return new server_1.MethodResult({});
        });
    }
    static update() {
        return __awaiter(this, void 0, void 0, function* () {
            return new server_1.MethodResult({});
        });
    }
    static delete(id) {
        return __awaiter(this, void 0, void 0, function* () {
            return new server_1.MethodResult(id);
        });
    }
};
__decorate([
    server_1.MethodMock({}),
    server_1.Method("GET" /* Get */, '/api/posts'),
    __param(0, server_1.Query('filter')), __param(1, server_1.Query('pageNumber')),
    __param(2, server_1.Query('pageSize')), __param(3, server_1.Request()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Number, Number, Object]),
    __metadata("design:returntype", Promise)
], TestController, "list", null);
__decorate([
    server_1.Method("GET" /* Get */, '/api/posts/:id'),
    __param(0, server_1.Param('id')), __param(1, server_1.Headers('host')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, String]),
    __metadata("design:returntype", Promise)
], TestController, "get", null);
__decorate([
    server_1.Method("GET" /* Get */, '/api/player/:player_name/desfaults'),
    __param(0, server_1.Param('player_name')),
    __param(1, server_1.Body()),
    __param(2, server_1.Headers()),
    __param(3, server_1.Files()),
    __param(4, server_1.Cookies()),
    __param(5, server_1.Query()),
    __param(6, server_1.Response()),
    __param(7, server_1.Request()),
    __param(8, server_1.SecurityContext()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object, Object, Object, Object, Object, Object, Object, Object]),
    __metadata("design:returntype", Promise)
], TestController, "listdefaults", null);
__decorate([
    server_1.MethodPipe("POST" /* Post */, '/api/player'),
    __param(0, server_1.Files('files')),
    __param(1, server_1.Cookies('cookies')), __param(2, server_1.Body('name')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object, String]),
    __metadata("design:returntype", Promise)
], TestController, "create", null);
__decorate([
    server_1.Method("GET" /* Get */, '/api/player/:player_id'),
    __param(0, server_1.Param('player_id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], TestController, "read", null);
__decorate([
    server_1.Method("GET" /* Get */, '/api/player/:field/:value'),
    __param(0, server_1.Param('field')), __param(1, server_1.Param('value')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Number]),
    __metadata("design:returntype", Promise)
], TestController, "getByField", null);
__decorate([
    server_1.Method("PUT" /* Put */, '/api/player'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], TestController, "update", null);
__decorate([
    server_1.Method("DELETE" /* Delete */, '/api/player/:id'),
    __param(0, server_1.Param('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], TestController, "delete", null);
TestController = TestController_1 = __decorate([
    server_1.MethodConfig('TestController')
], TestController);
exports.TestController = TestController;
//# sourceMappingURL=controller.test.js.map