UNPKG

typenexus

Version:

TypeNexus is a good tool for API encapsulation and management. It provides a clean and lightweight way to package TypeORM functionality, helping you build applications faster while reducing template code redundancy and type conversion work.

18 lines (16 loc) 617 B
import path from 'path'; import fs from 'fs'; import { __dirname, __filename } from './utils.js'; export async function getEntity(entityPath: string = '../entity') { const dirPath = path.resolve(__dirname, entityPath); const dirArr = (await fs.promises.readdir(dirPath)).filter((fileName) => !/(.js.map|.d.ts)$/.test(fileName)); const arr: string[] = []; dirArr.forEach((fileName) => { const ePath = path.resolve(dirPath, fileName).replace(/\.(js|ts)$/, ''); const handle = require(ePath); Object.keys(handle).forEach((funName) => { arr.push(handle[funName]); }); }); return arr; }