UNPKG

@fangcha/backend-kit

Version:
50 lines 2.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HealthDocItem = exports.HealthSpecs = void 0; const tslib_1 = require("tslib"); const router_1 = require("@fangcha/router"); const app_models_1 = require("@fangcha/app-models"); const main_1 = require("../../main"); const factory = new router_1.SpecFactory('Health Apis'); factory.prepare(app_models_1.RetainedHealthApis.Ping, (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { ctx.body = 'PONG'; })); factory.prepare(app_models_1.RetainedHealthApis.PingHealth, (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { yield main_1._FangchaState.checkHealth(); ctx.body = main_1._FangchaState.retainHealthWord || 'PONG'; })); factory.prepare(app_models_1.RetainedHealthApis.PingAuth, (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { ctx.body = 'PONG'; })); factory.prepare(app_models_1.RetainedHealthApis.PingPrint, (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { console.info('query: ', JSON.stringify(ctx.request.query, null, 2)); ctx.body = 'PONG'; })); factory.prepare(app_models_1.RetainedHealthApis.PingPrint2, (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { console.info('query: ', JSON.stringify(ctx.request.query, null, 2)); console.info('body: ', JSON.stringify(ctx.request.body, null, 2)); ctx.body = 'PONG'; })); factory.prepare(app_models_1.RetainedHealthApis.PingQuery, (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { ctx.body = ctx.request.query; })); factory.prepare(app_models_1.RetainedHealthApis.PingFullData, (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { ctx.body = { headers: ctx.request.headers, query: ctx.request.query, bodyData: ctx.request.body, }; })); factory.prepare(app_models_1.RetainedHealthApis.PingError, (_ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { throw new Error('Ping Error Test'); })); factory.prepare(app_models_1.RetainedHealthApis.SystemInfoGet, (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { ctx.body = main_1._FangchaState.appInfo(); })); exports.HealthSpecs = factory.buildSpecs(); exports.HealthDocItem = { name: '健康检查', pageURL: '/api-docs/v1/health', specs: exports.HealthSpecs, }; //# sourceMappingURL=HealthSpecs.js.map