You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

packages

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

packages

node-packages is [require.js](http://requirejs.org/) for node.js.


Version published
Maintainers
1
Created

Readme

Source

node-packages is require.js for node.js.

Motification

  • Flattens & simplifies application structure.
  • Better encapsulation.
  • More consistent.

Example

- package.json - application package
- lib/ - javascript source files
  - index.js - main entry point
    - packages/ - application components
      - config/ - application config component
      - http.server/ - http server component
        - index.js   - package entry point
      - http.routes/ - http routes
        - index.js   

In lib/index.js, you'll need something like:

var packages = require("packages");

packages.
require(__dirname + "/packages").
load();

In http.server/index.js, you might have something like:

exports.require = ["express", "config"];
exports.load = function (express, config) {
  var app = express()
  app.listen(config.get("port"));
  return app;
};

In http.routes/index.js, you might have something like:

exports.require = ["http.server"];
exports.load = function (app) {
  app.get("/hello", function (req, res) {
    res.send("Hello World!");
  });
};

Packages API

packages packages()

Initializes new packages loader

packages.add(name, package)

Adds a package. Below's an example where this might be useful.

lib/index.js:

var packages = require("packages");

module.exports = function (config) {
  packages.
  add("config", config).
  require(__dirname + "/packages").
  load();
}

lib/packages/http.server/index.js:

exports.require = ["config"];
exports.load = function(config) {
  //init server
}
packages.require(path[, path])

loads packages from a directory

packages.load()

loads all the packages

packages.exports

all the loaded packages

Package API

exports.require = [ "package.name", ["multiple.packages.*"], /package.to.match/ ];
exports.load    = function (singlePackage, multiplePackages, anotherSinglePackage, optionalSyncNext) {
  
};

FAQs

Package last updated on 10 Sep 2014

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc