Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

exporter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exporter

Help export your modules by file or directory and store in global

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-98.15%
Maintainers
1
Weekly downloads
 
Created
Source

Node Exporter

Useful modules exporter for global use.

We always need load modules with following codes:

var email = require('../../helpers/email')

If create much more files and directories, I will angry with using the absolute path. So there is a exporter, it is global definition for you.

Load modules:

var $ = require('exporter');

$('email', __dirname + '/email.js');

Use it

var $ = require('exporter');

// Use it
$.email('hfcorriez@gmail.com');

Install

npm install exporter

Usage

Export

In bootstrap file, such as app.js in Express.

Export variables

var $ = require('exporter');

// Load with variables
$.debug = true;
$.env = process.ENV['NODE_ENV'];

Export modules from file or directory

Project structure such as:

- app.js
- helpers/
  - uploader.js
  - image.js
  - email.js
  - tools/
    - guid.js

Export

// Set module directly
$.uploader = require('./helpers/uploader');

// Or use exporter
$.email = $(__dirname + '/helpers/email.js');

// And it's same as follow

// Or use function export only
$('email', __dirname + '/helpers/email.js');

// Export modules in directory
$.helpers = $(__dirname + './helpers');

// Export modules recursive in directory
$('allHelpers', __dirname + '/helpers', true);

Use exporter

In your process file or Express controller

var $ = require('exporter');

if ($.debug && $.env == 'product') {
    // Some logic
}

var guid = $.allHelpers.tools.guid();
var sendEmail = $.helpers.email;
var uploader = $.uploader;

More

In Express application. You can use to export all routes.

var $ = require('exporter');

$.routes = $(__dirname + '/routes', true);

If you have the structure such as:

- routes/
  - register.js
  - api/
    - users.js

And you can use it simply

var $ = require('exporter');

app.get('/register', $.routes.register);
app.get('/api/users', $.routes.api.users);

FAQs

Package last updated on 04 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc