bouquins/lib/bouquins.js

45 lines
875 B
JavaScript
Raw Normal View History

/**
* TODO license
* Bouquins module.
*/
2014-01-22 17:49:50 +00:00
GLOBAL.PATH_RE=/\/([a-zA-Z0-9]+)(?:\/|$)([a-zA-Z0-9]+)?/;
2014-01-22 19:20:43 +00:00
var Config = require('./util/config'),
logger = require('./util/logger'),
Router = require('./router/router'),
2014-01-22 19:20:43 +00:00
sqlite3 = require('sqlite3').verbose(),
bouquins = exports;
var router = null;
/**
* Load config file.
*/
bouquins.loadconfig = function(configfile, callback) {
2014-01-22 19:20:43 +00:00
Config.loadconfig(configfile, callback);
};
/**
* Init logger.
*/
bouquins.initLogger = function() {
if (config.debugLevel) {
logger.debugLevel = config.debugLevel;
}
return logger;
2014-01-22 19:20:43 +00:00
};
/**
* Init database.
*/
bouquins.initDB = function(callback) {
logger.debug('Database: '+config.dbfile);
GLOBAL.db = new sqlite3.Database(config.dbfile, callback);
};
/**
* Make main router.
*/
bouquins.makeRouter = function() {
if (!router) {
router = new Router();
}
return router;
2014-01-22 19:20:43 +00:00
};