UNPKG

nodo

Version:
25 lines (20 loc) 627 B
/** * Initializes the database connection * * @author Rogério Vicente <rogeriopvl@gmail.com> * @license MIT (see LICENSE file) */ var config = require('../lib/config'), sqlite = require('sqlite3').verbose(), fs = require('fs'), database = false, fileExists = false; if (config.file){ // this sucks, path.normalize should accept the home alias... var databaseLocation = config.file.database.location.replace(/~\//g, process.env.HOME + '/'); fileExists = fs.existsSync(databaseLocation); } if (fileExists){ database = new sqlite.Database(databaseLocation); } module.exports = database;