Build a blog with Areto Node.js framework

Primary init

In most applications, after installation, you must make an primary database initialization. It is necessary to add an administrator and other params. Start initialization by a separate script.


const app = require('../module');
const MainHelper = require('areto/helpers/MainHelper');
app.configure('development', err => {
    if (err) {
        return console.error(err);
    app.migrate(MainHelper.getScriptArgs(), err => {

Create the migrations directory and add the Init class to it. The class will create the Administrator user with the admin role. In the future, administrator can sign in to the application control module and create other users by the web interface.


const Base = require('areto/db/Migration');
const User = require('../models/User');
module.exports = class Init extends Base {
  apply (cb) {
     this.execute(cb, [
        cb => {
           let user = new User;
              name: 'Administrator',
              email: 'a@a.a',
              role: 'admin',
              password: '123456'

You can run the script either from the command line, go to the blog directory:

node bin/migrate.js apply migrations/Init

Either using WebStorm:

Edit configurations -> Add new -> Node.js
Name: Init Areto Blog
Working directory: areto-blog
Javascript file: bin/migrate.js
Application parameters: apply migrations/Init