Moved eveything related to the api to a seperate folder seasoned_api.

This commit is contained in:
2017-08-06 16:45:02 +02:00
parent f53ab55d96
commit 47aa638fd8
44 changed files with 7 additions and 7 deletions

View File

@@ -0,0 +1,15 @@
const configuration = require('src/config/configuration').getInstance();
const SqliteDatabase = require('src/database/sqliteDatabase');
const database = new SqliteDatabase(configuration.get('database', 'host'));
/**
* This module establishes a connection to the database
* specified in the confgiuration file. It tries to setup
* the required tables after successfully connecting.
* If the tables already exists, it simply proceeds.
*/
Promise.resolve()
.then(() => database.connect())
// .then(() => database.setUp());
module.exports = database;

View File

@@ -0,0 +1,32 @@
const fs = require('fs');
const path = require('path');
const sqlite3 = require('sqlite3');
class SqliteDatabase {
constructor(host) {
this.host = host;
this.connection = sqlite3;
// this.schemaDirectory = path.join(__dirname, 'schemas');
}
connect() {
return Promise.resolve()
.then(() => new sqlite3.Database(this.host))
}
all(sql, parameters) {
return this.connection.all(sql, parameters);
}
get(sql, parameters) {
return this.connection.get(sql, parameters);
}
run(sql, parameters) {
return this.connection.run(sql, parameters);
}
}
module.exports = SqliteDatabase;