"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReportMiddleware = void 0;
const decorator_1 = require("@midwayjs/decorator");
let ReportMiddleware = class ReportMiddleware {
    resolve() {
        return async (ctx, next) => {
            // 控制器前执行的逻辑
            const startTime = Date.now();
            // 执行下一个 Web 中间件，最后执行到控制器
            // 这里可以拿到下一个中间件或者控制器的返回值
            const result = await next();
            // 控制器之后执行的逻辑
            const executeTime = Date.now() - startTime;
            ctx.logger.info(`Report in "src/middleware/report.middleware.ts", rt = ${executeTime}ms`);
            if (typeof result === 'object' && !ctx.ignoreFormat) {
                result.executeTime = executeTime;
            }
            // 返回给上一个中间件的结果
            return result;
        };
    }
    ignore(ctx) {
        return (ctx.path.indexOf('/docs') === 0 ||
            ctx.path.indexOf('/resource/console') === 0 ||
            ctx.path.indexOf('/types') === 0);
    }
    static getName() {
        return 'report';
    }
};
ReportMiddleware = __decorate([
    (0, decorator_1.Middleware)()
], ReportMiddleware);
exports.ReportMiddleware = ReportMiddleware;
//# sourceMappingURL=report.middleware.js.map