UNPKG

api-service-core

Version:

NodeJS api-service

48 lines 1.7 kB
"use strict"; /************************************************************************* * * Troven CONFIDENTIAL * __________________ * * (c) 2017-2019 Troven Pty Ltd * All Rights Reserved. * * NOTICE: All information contained herein is, and remains * the property of Troven Pty Ltd and its licensors, * if any. The intellectual and technical concepts contained * herein are proprietary to Troven Pty Ltd * and its suppliers and may be covered by International and Regional Patents, * patents in process, and are protected by trade secret or copyright law. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Troven Pty Ltd. */ Object.defineProperty(exports, "__esModule", { value: true }); const assert = require("assert"); class debug { constructor() { this.name = "api.debug"; this.title = "Audit-only debug policy"; } fn(operation, _options) { let options = _options; let pkg = operation.context.pkg; return function (req, res, next) { assert(req && res && next, "invalid middleware"); let cmd = req.method + " " + req.path; let msg = options.message || cmd; operation.context.log({ uuid: operation.context.uuid, name: pkg.name, version: pkg.version, request: cmd, // request_uuid: res.get(request_uuid.options.header), code: "api:policy:debug", message: msg }); next(); }; } } exports.default = debug; //# sourceMappingURL=debug.js.map