Merge branch 'master' of github.com:kevinmidboe/seasonedShows

This commit is contained in:
2018-01-09 22:51:26 +01:00
10 changed files with 64 additions and 13 deletions

View File

@@ -1,10 +1,10 @@
{ {
'dist': 'trusty', 'dist': 'trusty',
'language': 'node_js', 'language': 'node_js',
'node_js': '6.9.5', 'node_js': '8.7.0',
'cache': 'yarn', 'cache': 'yarn',
'scripts': [ 'scripts': [
npm run test 'npm run test'
], ],
'before_install': [ 'before_install': [
'cd seasoned_api', 'cd seasoned_api',

View File

@@ -1,5 +1,8 @@
# 🌶 seasonedShows # 🌶 seasonedShows
Your customly seasoned movie and show requester, downloader and organizer [![Build Status](https://travis-ci.org/KevinMidboe/seasonedShows.svg?branch=master)](https://travis-ci.org/KevinMidboe/seasonedShows)
[![DUB](https://img.shields.io/dub/l/vibe-d.svg)]()
Your customly *seasoned* movie and show requester, downloader and organizer.
## About ## About
The goal of this project is to create a full custom stack that can to everything surround downloading, organizing and notifiyng of new media. From the top down we have a website using [tmdb](https://www.themoviedb.com) api to search for from over 350k movies and 70k tv shows. Using [hjone72](https://github.com/hjone72/PlexAuth) great PHP reverse proxy we can have a secure way of allowing users to login with their plex credentials which limits request capabilites to only users that are authenticated to use your plex library. The goal of this project is to create a full custom stack that can to everything surround downloading, organizing and notifiyng of new media. From the top down we have a website using [tmdb](https://www.themoviedb.com) api to search for from over 350k movies and 70k tv shows. Using [hjone72](https://github.com/hjone72/PlexAuth) great PHP reverse proxy we can have a secure way of allowing users to login with their plex credentials which limits request capabilites to only users that are authenticated to use your plex library.

View 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"
}
}

View File

@@ -3,14 +3,15 @@
"main": "webserver/server.js", "main": "webserver/server.js",
"scripts": { "scripts": {
"start": "cross-env SEASONED_CONFIG=conf/development.json NODE_PATH=. node src/webserver/server.js", "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/" "lint": "./node_modules/.bin/eslint src/webserver/"
}, },
"dependencies": { "dependencies": {
"bcrypt-nodejs": "^0.0.3", "bcrypt-nodejs": "^0.0.3",
"body-parser": "~1.0.1", "body-parser": "~1.0.1",
"cross-env": "^3.1.3", "cross-env": "^3.1.3",
"eslint": "^4.9.0", "express": "~4.11.0",
"express": "~4.0.0",
"jsonwebtoken": "^8.0.1", "jsonwebtoken": "^8.0.1",
"mongoose": "^3.6.13", "mongoose": "^3.6.13",
"moviedb": "^0.2.10", "moviedb": "^0.2.10",
@@ -20,11 +21,17 @@
"raven": "^2.2.1", "raven": "^2.2.1",
"request": "^2.81.0", "request": "^2.81.0",
"request-promise": "^4.2", "request-promise": "^4.2",
"sqlite": "^2.2.1", "sqlite": "^2.9.0"
"sqlite3": "^2.5.0"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^4.9.0",
"eslint-config-airbnb-base": "^12.1.0", "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"
} }
} }

View File

@@ -27,6 +27,11 @@ class Config {
const field = new Field(this.fields[section][option]) 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) { if (field.value === undefined) {
throw new Error(`${section} => ${option} is empty.`); throw new Error(`${section} => ${option} is empty.`);
} }

View File

@@ -4,7 +4,7 @@ const EnvironmentVariables = require('./environmentVariables.js');
class Field { class Field {
constructor(rawValue, environmentVariables) { constructor(rawValue, environmentVariables) {
this.rawValue, rawValue; this.rawValue = rawValue;
this.filters = new Filters(rawValue); this.filters = new Filters(rawValue);
this.valueWithoutFilters = this.filters.removeFiltersFromValue(); this.valueWithoutFilters = this.filters.removeFiltersFromValue();
this.environmentVariables = new EnvironmentVariables(environmentVariables); this.environmentVariables = new EnvironmentVariables(environmentVariables);

View File

@@ -10,7 +10,7 @@ class Filters {
} }
isEmpty() { isEmpty() {
return !this.hasValidType() || this.filters.length === 0; return !this.hasValidType() || this.value.length === 0;
} }
has(filter) { has(filter) {

View File

@@ -0,0 +1,3 @@
DROP TABLE IF EXISTS user;
DROP TABLE IF EXISTS search_history;
DROP TABLE IF EXISTS requests;

View File

@@ -69,6 +69,15 @@ class SqliteDatabase {
return this.execute(setupSchema); 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 the file contents of a SQL file in schemas/.
* @returns {String} * @returns {String}

View File

@@ -4,7 +4,7 @@ function resetDatabase() {
const database = new SqliteDatabase(':memory:'); const database = new SqliteDatabase(':memory:');
return Promise.resolve() return Promise.resolve()
.then(() => database.connect()) .then(() => database.connect())
.then(() => database.tearDown()) // .then(() => database.tearDown())
.then(() => database.setUp()); .then(() => database.setUp());
} }