UNPKG

@geniucode/common-utils

Version:

Common utils

35 lines 1.22 kB
import { httpResponse } from '../http-response'; export const healthCheck = (serviceName, req, res) => { let headers; try { headers = Object.entries(req.headers).map(([key, value]) => `${key}: ${value}`); const customResponseData = { packageVersion: '1.0.0', status: true, statusCode: 200, devCode: null, isValid: true, project: serviceName, datetime: new Date().toLocaleString(), datetimeISO: new Date().toISOString(), datetimeUTC: new Date().toUTCString(), httpMethod: req?.method, url: req?.url, originalUrl: req?.originalUrl, path: req?.path, subdomains: req?.subdomains, hostname: req?.hostname, ip: req?.ip, isAjaxCall: req?.xhr, protocol: req?.protocol, secure: req?.secure, headers: headers, route: req?.route, }; httpResponse.ok(res, customResponseData, `${serviceName} is up and running`); } catch (error) { httpResponse.badRequest(res, error?.mesage); } }; //# sourceMappingURL=health-check.js.map