0.0.4 • Published 6 years ago

abrequire v0.0.4

Weekly downloads
55
License
MIT
Repository
github
Last release
6 years ago

abrequire

A-B-Require is pretty require with absolute path. Simply Easy Smaller < 1Kb

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const mysql = require('../../../../db/mysql')

Those suck for maintenance and they're ugly. link

Install

npm install abrequire --save

How to use

global.use = require('abrequire')

or

const use = require('abrequire')

Example

-root
--app
----db
------mysql.js
------mongoose.js
----routes
------group
---------subGroup
------------router.js
--server.js
--node_module
--package.json

When router.js require mysql.js relative path

const mysql = require('../../../../db/mysql')

When router.js require mysql.js absolute path

const use = require('abrequire')
const mysql = use('app/db/mysql')

Authors

License

This project is licensed under the MIT License