UNPKG

dazjsx

Version:

参考nestjs,基于KOA2的一款轻量级的后端开发框架

36 lines (35 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Tool = void 0; const __1 = require(".."); class Tool { static isNotEmptyArray(val) { return Array.isArray(val) && val[0]; } static isNotEmptyObject(val) { return (Object.prototype.toString.call(val).toLowerCase() === '[object object]' && Object.keys(val).length > 0); } static isIoc(val) { const isOk = this.isNotEmptyObject(val); if (isOk) { return !!val.useFactory; } return false; } static async waiting(time = 0) { return new Promise((resolve) => setTimeout(resolve, time * 1000)); } static getController(prefix, name) { return prefix || name.toLowerCase().replace(__1.Constant.CL, __1.Constant.NL); } static getPath(prefix, path) { path = path === __1.Constant.DP ? __1.Constant.NL : path; return `${__1.Constant.DP}${prefix.replace(__1.Constant.DP, __1.Constant.NL)}${path}`; } static getParams(request, type) { const record = (__1.PARAMS.includes(type) && request[type]) || {}; return (key) => (key ? record[key] : record); } } exports.Tool = Tool;