/ hello_world / config will store configuration files here /main.js one is enough for a start / controllers here we will add controllers that define the logic of our outstanding application /site.js is the only controller with a single action for a single page. / views place for views /index.html main page view /index.js input script
cd hello_world npm install autodafe
var config = require( './config/main' ); var autodafe = require( 'autodafe' ); autodafe.create_application( config ).run();
module.exports = { // ( ) name : 'hello_world', // , , , , // , base_dir : require('path').join( __dirname, '..' ), // , Application.get_param params : { your_name : 'Andrey' // }, // router : { rules : { '/' : 'site.index' } }, // components : { // http http : { port : 3000 } } };
// Controller module.exports = Site.inherits( global.autodafe.Controller ); /** * , */ function SiteController( params ) { this._init( params ); } /** * . router.rules */ SiteController.prototype.index = function ( response, request ) { // index.html response.send({ name : this.app.params['your_name' ] } ); };
<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>Autodafe hello world</title> </head> <body> <h1>Hello {name}!</h1> </body> </html>
node index.js
Source: https://habr.com/ru/post/135089/