Build a blog with Areto Framework

The first controller

The Areto Node.js framework uses the MVC pattern (Model - View - Controller) popular among web applications for interaction between the different parts of app.

Default Controller

Create the controllers directory in the root of the project and append the DefaultController.js file. Filename is the name for exported class. Controller class inherits from the area/base/Controller framework class.

Create the actionIndex class method. All controller methods with the action prefix are defined as actions (handlers) for respective routes. For example, actionNewPost will be called when handling at http://localhost:3000/default/new-post.

The last line contains initialization of static class variables and bind to node module.

controller/DefaultController.js

const Base = require('areto/base/Controller');
module.exports = class DefaultController extends Base {

  actionIndex () {
    this.send('<h1>Hello blog!</h1>');
  }
};
module.exports.init(module);

Server restart

Start web server. You will see a welcome at http://localhost:3000/default/index.