Package Exports
- approot
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (approot) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
approot

An utility to build path based on a base path. Useful in node.js application, such as web app server. Recommend to instantiate an
approotin global namespace, to provide an specific reference path across all files in the project
Install
Install using npm.
$ npm install approotUsage
// suppose __dirname is /var/application
// build approot based on __dirname
global.approot = require('approot')(__dirname).consolidate();
// put approot in global to share it across files in the app
approot() // return /var/application
approot('data', 'sample.json') // return /var/application/data/sample.json
approot.models() // return /var/application/models, exists after consolidate is called
approot.models('user.js') // return /var/application/models/user.js
// equivalent to call approot.consolidate().data.consolidate().important.consolidate()
approot.consolidate('data', 'important')
approot.listChildren() // list all files and folders in current folder
approot.listChildren('sub', 'grandsub') // list all files and folders in './sub/grandsub'
When used in conjunction of lazily-require to initialize the application environment.
var lazy = require('lazily-require');
global.appRoot = require('approot')(__dirname).consolidate();
global.configuration = require(appRoot.config('configuration'));
global.Services = lazy appRoot.services();
global.Routes = lazy appRoot.routes();
global.Records = lazy appRoot.records();
global.Models = lazy appRoot.models();
global.Entities = lazy appRoot.entities();
// Reference as
var user = Models.User;
var user = new User();
var user2 = new Models.User();
app.get('/admin/login', Routers.admin.login.get);
License
MIT