UNPKG

api-service-core

Version:

NodeJS api-service

46 lines 1.61 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 }); /** * Heartbeat * --------- * Attach a heartbeat to a OpenAPI resource * * @type {{name: string, description: string, title: string, defaults: {path: string}, fn: module.exports.fn}} */ class heartbeat { constructor() { this.name = "api.heartbeat"; this.title = "return a simple heartbeat"; } fn(operation, _options) { let context = operation.context; return function (_req, res) { let req_uuid = res.getHeader("X-REQUEST-UUID"); // simple heartbeat - echos query params - intended for generic correlation context.log({ code: "api:heartbeat", request: req_uuid }); res.status(200); res.send({ ok: req_uuid }); }; } } exports.default = heartbeat; ; //# sourceMappingURL=heartbeat.js.map