0.4.8-alpha • Published 2 years ago

@pho-cms/loader v0.4.8-alpha

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Loader

Simple load file for Nodejs

Motivation

  • Publish minimal packages to npm
  • Eliminated the problem of remembering file paths when using function require of nodejs

Config

  • Support for nodejs - javascript
  • Need to a file loader.tree.json in workdir of project

Usage

Installation

npm i --save @pho-cms/loader

Setup

  • Command for caching
npx pho-loader cache

OR

pho-loader cache

Code

At workdir of the project generate file loader.tree.json with sample content:

{
    "cache_folder_path": ".", 
    "dir_tree": {
        "app": {
            "controllers": {
                "alias_name": "appController",
            },
            "interceptors": {
                "middleware": {},
                "requests": {},
                "responses": {}
            },
            "models": {}
        },
        "configs": {},
        "bootstrap": {}
    }
}

cache_folder_path is path folder where the file cache will generate

dir_tree is a tree file description in the project, each directory is like a work namespace

alias_name is alias of namespace app/controller

Ex. in file index.js in root folder

  • structure
|app
|_ controllers
|__demo.controller.js
|configs
|_ demo.config.js
  • loader.tree.json
{
    "cache_folder_path": ".", 
    "dir_tree": {
        "app": {
            "controllers": {
                "alias_name": "appController",
            },
        },
        "configs": {},
    }
}
const Loader = require("@pho-cms/loader")

const config = Loader.use("configs", "demo.config")

//case 1
const demoController = Loader.use("app/http/controllers", "demo.controller")

//case 2
const demoController = Loader.use("appControllers", "demo.controller")
0.4.8-alpha

2 years ago

0.4.7-alpha

2 years ago

0.4.6-alpha

2 years ago

0.4.5-alpha

2 years ago

0.4.4-alpha

2 years ago

0.4.3-alpha

2 years ago

0.4.2-alpha

2 years ago

0.4.1-alpha

2 years ago

0.4.0-alpha

2 years ago

0.3.0-alpha

2 years ago

0.2.0-alpha

2 years ago

0.1.0-alpha

2 years ago

0.0.5-alpha

2 years ago

0.0.4-alpha

2 years ago

0.0.3-alpha

2 years ago

0.0.2-alpha

2 years ago

0.0.1-alpha

2 years ago