Пример #1
0
// We can't use the sql or task helpers because the database does not exist yet.
function query (sql, next) {
  delete require.cache[require.resolve('cantina')];
  delete require.cache[require.resolve('cantina-mysql')];

  var app = require('cantina');
  app.load(function(err) {
    if (err) throw err;

    var database = app.conf.get('mysql:database');
    app.conf.set('mysql:database', null);

    require(app.root + '/plugins/utils');
    require('cantina-mysql');

    app.init(function(err) {
      if (err) throw err;

      app.mysql.query(sql.replace('[db]', database), function(err) {
        if (err) throw err;

        app.utils.clearRequireCache();
        next();
      });
    });
  });
}
Пример #2
0
var app = require('cantina')
 ,  path = require('path');

app.load(function (err) {
  if (err) return console.error(err);

  require(app.plugins.http);
  require(app.plugins.middleware);
  require('./plugins/logger');
  require(app.plugins.static);
  require(app.plugins.controllers);
  require('cantina-views');

  app.views.registerPartials(path.resolve(app.root, 'views/partials'));

  app.init();
});