Start with NodeAtlas
We will start with a how to set minimal files to perform a hello-world
.
Fileset
After installing NodeAtlas somewhere on your machine, you create a set of files representing a site anywhere else like structure below.
site-hello-world/
├─ templates/
│ └─ index.htm
└─ webconfig.json
Here is the "/site-hello-world/templates/index.htm" file:
<!DOCTYPE html>
<html lang="fr-fr">
<head>
<meta charset="utf-8" />
<title>Hello world</title>
</head>
<body>
<div>This is a Hello World!</div>
</body>
</html>
and following, the "/site-hello-world/webconfig.json" file.
Minimum Requirements
You can turn a simple page with minimal configuration "webconfig.json" below
{
"routes": {
"/": {
"template": "index.htm"
}
}
}
equivalent to
{ "routes": { "/": "index.htm" } }
Run the site with NodeAtlas
With a command line
Position yourself with the prompt console in the folder "/Site-hello-world/" and run the following command.
\> node </path/to/>node-atlas/
You will have access to your "Hello World" to the page: http://localhost/ in a browser.
With an executable on your OS
If you have installed NodeAtlas with npm install -g node-atlas
you can also use the nodeatlas
command. nodeatlas
is a shortcut for node </path/to/>node-atlas/
.
Position yourself with the prompt console in the folder « /site-hello-world/ » and run the following command.
\> nodeatlas
Note : if the nodeatlas
command do not work on unix OS after installation, it's probably because of right problem. If you are root, the command chown -R root:root /usr/local/bin/
before re-execuse npm install -g node-atlas
command will fix issue, else, use the command sudo npm install -g node-atlas
.*
Via a JavaScript file
You can also use NodeAtlas as a npm module.
server.js
var nodeAtlas = require("node-atlas");
nodeAtlas().run();
\> node server.js