# packages

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

Latest version **0.0.8** (published 2014-09-10) · BSD license · 0 weekly downloads

## Install

```sh
npm install packages
pnpm add packages
yarn add packages
bun add packages
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2014-09-10 |
| First published | 2013-09-14 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | architectd |

## Links

- npm: https://www.npmjs.com/package/packages
- Repository: https://github.com/classdojo/node-packages
- Issues: https://github.com/classdojo/node-packages/issues
- npm.io page: https://npm.io/package/packages

## Dependencies (5)

- [express](https://npm.io/package/express.md) ~3.4.0
- [toarray](https://npm.io/package/toarray.md) 0.0.1
- [resolver](https://npm.io/package/resolver.md) ~0.1.11
- [factories](https://npm.io/package/factories.md) 0.0.x
- [type-component](https://npm.io/package/type-component.md) 0.0.1

## Recent versions

- 0.0.8 (latest) — 2014-09-10
- 0.0.7 — 2014-09-10
- 0.0.6 — 2014-09-10
- 0.0.5 — 2014-02-06
- 0.0.4 — 2013-10-18
- 0.0.3 — 2013-09-14
- 0.0.2 — 2013-09-14
- 0.0.1 — 2013-09-14

## README

node-packages is [require.js](http://requirejs.org/) 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:

```javascript
var packages = require("packages");

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

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

```javascript
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:

```javascript
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`:

```javascript
var packages = require("packages");

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

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

```javascript
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


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

---
_Source: https://npm.io/package/packages · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
