UNPKG

devlien

Version:

Devlien is a lightweight, zero-dependency Node.js framework with clean MVC structure, built-in ORM, and intuitive routing for rapid backend development.

44 lines (35 loc) 1.14 kB
import { pathToFileURL } from 'url'; import { baseEnv } from "devlien/env"; import fs from "fs"; import path from "path"; export default class System { base_path = ''; constructor(config = {path:''}) { this.base_path = config.path ? config.path : ''; } path($string=""){ return path.join(baseEnv.BASE_PATH, ($string!='' ? (this.base_path+'/'+$string) : this.base_path)); } static path($string=""){ let obj = new System; return path.join(baseEnv.BASE_PATH, ($string!='' ? (obj.base_path+'/'+$string) : obj.base_path)); } static vendorPath($string=""){ return path.join(process.cwd(), 'node_modules/devlien', $string); } static readDirAsync(dirPath) { return new Promise((resolve, reject) => { fs.readdir(dirPath, (err, files) => { if (err) reject(err); else resolve(files); }); }); } static toFilePath(path=''){ return pathToFileURL(path).href; } static async import(path=''){ return (await import(pathToFileURL(path).href)).default; } }