NodeAtlas

API / NodeAtlas as npm module

You could run NodeAtlas via JavaScript code.

<node-atlas-instance>.init()

Execute a simple NodeAtlas running with init(). By default, it use webconfig.json from directory where file is executed. If no webconfig.json is set, a Simple Web Server will be launched.

server.js

require("node-atlas")().init();
\> server server.js
``



### &lt;node-atlas-instance>.config(Object) ###

You can also configure the launch with `config(Object)`:

*server.js*

```javascript
require("node-atlas")().config({
    directory: "/path/to/your/website/directory/",
    webconfig: "webconfig.alternatif.json",
    browse: true,
    httpHostname: "192.168.1.1",
    httpPort: 7778,
    generate: true
}).init();
\> node server.js

<node-atlas-instance>.run(Object)

With run(Object) you could configure and lanch NodeAtlas with one command.

You can for example run multiple websites in same time. Each webconfig must listen a different port.

servers.js

var nodeAtlas = require("node-atlas"),
    websiteEn = new nodeAtlas(),
    websiteFr = new nodeAtlas();

websiteEn.run({
    "browse": true,
    "webconfig": "webconfig.english.json"
});
websiteFr.run({
    "browse": true,
    "webconfig": "webconfig.french.json"
});

<node-atlas-instance>.started(Function)

With started(Function), you could also execute other tasks after server ran:

servers.js

require("node-atlas")().started(function() {
    console.log("Server started!");
}).run({
    browse: true
});

<node-atlas-instance>.generated(Function)

With generated(Function), you could also execute other tasks after assets generation:

servers.js

require("node-atlas")().generated(function() {
    require('child_process').exec(__dirname + "/documentation.bat", function (err, stdout, stderr) {
        console.log("Documentation generation...");
        console.log(stdout);
        console.log("Documentation generation done !");
    });
}).run({
    generate: true
});

<node-atlas-instance>.created(Function)

With created(Function), you could also execute other tasks after init the current directory with template website:

servers.js

var nodeAtlas = require("node-atlas"),
    website = nodeAtlas();

website.config({
    "init": true
}).created(function() {
    website.run({
        "browse": true
    });
}).init();