24
seasoned_api/conf/development.json
Normal file
24
seasoned_api/conf/development.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"database": {
|
||||
"host": "../shows.db"
|
||||
},
|
||||
"webserver": {
|
||||
"port": 31459
|
||||
},
|
||||
"tmdb": {
|
||||
"apiKey": ""
|
||||
},
|
||||
"raven": {
|
||||
"DSN": ""
|
||||
},
|
||||
"mail": {
|
||||
"host": "",
|
||||
"user": "",
|
||||
"password": "",
|
||||
"user_pi": "",
|
||||
"password_pi": ""
|
||||
},
|
||||
"authentication": {
|
||||
"secret": "secret"
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,14 @@
|
||||
"main": "webserver/server.js",
|
||||
"scripts": {
|
||||
"start": "cross-env SEASONED_CONFIG=conf/development.json NODE_PATH=. node src/webserver/server.js",
|
||||
"test": "cross-env SEASONED_CONFIG=conf/development.json NODE_PATH=. mocha --recursive test/system",
|
||||
"coverage": "cross-env PLANFLIX_CONFIG=conf/test.json NODE_PATH=. istanbul cover -x script/autogenerate-documentation.js --include-all-sources --dir test/.coverage node_modules/mocha/bin/_mocha --recursive test/**/* -- --report lcovonly && cat test/.coverage/lcov.info | coveralls && rm -rf test/.coverage",
|
||||
"lint": "./node_modules/.bin/eslint src/webserver/"
|
||||
},
|
||||
"dependencies": {
|
||||
"bcrypt-nodejs": "^0.0.3",
|
||||
"body-parser": "~1.0.1",
|
||||
"cross-env": "^3.1.3",
|
||||
"eslint": "^4.9.0",
|
||||
"express": "~4.0.0",
|
||||
"jsonwebtoken": "^8.0.1",
|
||||
"mongoose": "^3.6.13",
|
||||
@@ -20,11 +21,16 @@
|
||||
"raven": "^2.2.1",
|
||||
"request": "^2.81.0",
|
||||
"request-promise": "^4.2",
|
||||
"sqlite": "^2.2.1",
|
||||
"sqlite3": "^2.5.0"
|
||||
"sqlite": "^2.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint-config-airbnb-base": "^12.1.0",
|
||||
"eslint-plugin-import": "^2.8.0"
|
||||
"eslint-plugin-import": "^2.8.0",
|
||||
"eslint": "^4.9.0",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.1.0",
|
||||
"supertest": "^2.0.1",
|
||||
"supertest-as-promised": "^4.0.1"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ class Config {
|
||||
|
||||
const field = new Field(this.fields[section][option])
|
||||
|
||||
if (field.value === '') {
|
||||
const envField = process.env[[section.toUpperCase(), option.toUpperCase()].join('_')]
|
||||
if (envField !== undefined && envField.length !== 0) { return envField }
|
||||
}
|
||||
|
||||
if (field.value === undefined) {
|
||||
throw new Error(`${section} => ${option} is empty.`);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ const EnvironmentVariables = require('./environmentVariables.js');
|
||||
class Field {
|
||||
|
||||
constructor(rawValue, environmentVariables) {
|
||||
this.rawValue, rawValue;
|
||||
this.rawValue = rawValue;
|
||||
this.filters = new Filters(rawValue);
|
||||
this.valueWithoutFilters = this.filters.removeFiltersFromValue();
|
||||
this.environmentVariables = new EnvironmentVariables(environmentVariables);
|
||||
|
||||
@@ -10,7 +10,7 @@ class Filters {
|
||||
}
|
||||
|
||||
isEmpty() {
|
||||
return !this.hasValidType() || this.filters.length === 0;
|
||||
return !this.hasValidType() || this.value.length === 0;
|
||||
}
|
||||
|
||||
has(filter) {
|
||||
|
||||
3
seasoned_api/src/database/schemas/teardown.sql
Normal file
3
seasoned_api/src/database/schemas/teardown.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
DROP TABLE IF EXISTS user;
|
||||
DROP TABLE IF EXISTS search_history;
|
||||
DROP TABLE IF EXISTS requests;
|
||||
@@ -69,6 +69,15 @@ class SqliteDatabase {
|
||||
return this.execute(setupSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the database by running tearDown.sql file in schemas/.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
tearDown() {
|
||||
const tearDownSchema = this.readSqlFile('tearDown.sql');
|
||||
return this.execute(tearDownSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file contents of a SQL file in schemas/.
|
||||
* @returns {String}
|
||||
|
||||
@@ -4,7 +4,7 @@ function resetDatabase() {
|
||||
const database = new SqliteDatabase(':memory:');
|
||||
return Promise.resolve()
|
||||
.then(() => database.connect())
|
||||
.then(() => database.tearDown())
|
||||
// .then(() => database.tearDown())
|
||||
.then(() => database.setUp());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user