diff --git a/.travis.yml b/.travis.yml index 3140bb8..6f664eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,14 @@ { 'dist': 'trusty', 'language': 'node_js', - 'node_js': '6.9.5', + 'node_js': '8.7.0', 'cache': 'yarn', 'scripts': [ - npm run test + 'npm run test' ], 'before_install': [ 'cd seasoned_api', ], 'before_script': 'yarn', 'os': 'linux', -} \ No newline at end of file +} diff --git a/README.md b/README.md index ffa6c70..0466557 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # 🌶 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 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. diff --git a/seasoned_api/conf/development.json b/seasoned_api/conf/development.json new file mode 100644 index 0000000..abf8399 --- /dev/null +++ b/seasoned_api/conf/development.json @@ -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" + } +} diff --git a/seasoned_api/package.json b/seasoned_api/package.json index 8ac0fe3..7814f28 100644 --- a/seasoned_api/package.json +++ b/seasoned_api/package.json @@ -3,15 +3,16 @@ "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", + "express": "~4.11.0", + "jsonwebtoken": "^8.0.1", "mongoose": "^3.6.13", "moviedb": "^0.2.10", "node-cache": "^4.1.1", @@ -20,11 +21,17 @@ "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": "^4.9.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" + } } diff --git a/seasoned_api/src/config/configuration.js b/seasoned_api/src/config/configuration.js index c8aa9a2..bd9d4c3 100644 --- a/seasoned_api/src/config/configuration.js +++ b/seasoned_api/src/config/configuration.js @@ -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.`); } diff --git a/seasoned_api/src/config/field.js b/seasoned_api/src/config/field.js index 2dbfc58..1a8b79a 100644 --- a/seasoned_api/src/config/field.js +++ b/seasoned_api/src/config/field.js @@ -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); diff --git a/seasoned_api/src/config/filters.js b/seasoned_api/src/config/filters.js index ebd813d..fbeab07 100644 --- a/seasoned_api/src/config/filters.js +++ b/seasoned_api/src/config/filters.js @@ -10,7 +10,7 @@ class Filters { } isEmpty() { - return !this.hasValidType() || this.filters.length === 0; + return !this.hasValidType() || this.value.length === 0; } has(filter) { diff --git a/seasoned_api/src/database/schemas/teardown.sql b/seasoned_api/src/database/schemas/teardown.sql new file mode 100644 index 0000000..750cbab --- /dev/null +++ b/seasoned_api/src/database/schemas/teardown.sql @@ -0,0 +1,3 @@ +DROP TABLE IF EXISTS user; +DROP TABLE IF EXISTS search_history; +DROP TABLE IF EXISTS requests; diff --git a/seasoned_api/src/database/sqliteDatabase.js b/seasoned_api/src/database/sqliteDatabase.js index 5ac1330..a68e207 100644 --- a/seasoned_api/src/database/sqliteDatabase.js +++ b/seasoned_api/src/database/sqliteDatabase.js @@ -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} diff --git a/seasoned_api/test/helpers/resetDatabase.js b/seasoned_api/test/helpers/resetDatabase.js index 2498852..fdb5c0b 100644 --- a/seasoned_api/test/helpers/resetDatabase.js +++ b/seasoned_api/test/helpers/resetDatabase.js @@ -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()); }