mirror of
https://github.com/mjrode/WhatToWatch.git
synced 2026-01-04 04:30:41 -06:00
Move all DB dependencies to DB folder.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
var path = require('path')
|
||||
|
||||
module.exports = {
|
||||
'models-path': path.resolve('server', 'models'),
|
||||
|
||||
config: path.resolve('server', 'db', 'config', 'config.json'),
|
||||
'models-path': path.resolve('server', 'db', 'models'),
|
||||
'seeders-path': path.resolve('server', 'db', 'seeders'),
|
||||
'migrations-path': path.resolve('server', 'db', 'migrations')
|
||||
}
|
||||
@@ -20,24 +20,24 @@
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">87.62% </span>
|
||||
<span class="strong">87.63% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>177/202</span>
|
||||
<span class='fraction'>170/194</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">68.97% </span>
|
||||
<span class="strong">73.91% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>20/29</span>
|
||||
<span class='fraction'>17/23</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">83.02% </span>
|
||||
<span class="strong">83.33% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>44/53</span>
|
||||
<span class='fraction'>45/54</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">87.56% </span>
|
||||
<span class="strong">87.5% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>176/201</span>
|
||||
<span class='fraction'>168/192</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="quiet">
|
||||
@@ -114,16 +114,16 @@
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file high" data-value="recommend/server/models"><a href="recommend/server/models/index.html">recommend/server/models</a></td>
|
||||
<td data-value="97.22" class="pic high"><div class="chart"><div class="cover-fill" style="width: 97%;"></div><div class="cover-empty" style="width:3%;"></div></div></td>
|
||||
<td data-value="97.22" class="pct high">97.22%</td>
|
||||
<td data-value="36" class="abs high">35/36</td>
|
||||
<td data-value="66.67" class="pct medium">66.67%</td>
|
||||
<td data-value="9" class="abs medium">6/9</td>
|
||||
<td class="file high" data-value="recommend/server/db/models"><a href="recommend/server/db/models/index.html">recommend/server/db/models</a></td>
|
||||
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="9" class="abs high">9/9</td>
|
||||
<td data-value="97.22" class="pct high">97.22%</td>
|
||||
<td data-value="36" class="abs high">35/36</td>
|
||||
<td data-value="28" class="abs high">28/28</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="3" class="abs high">3/3</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="10" class="abs high">10/10</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="27" class="abs high">27/27</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -158,7 +158,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="prettify.js"></script>
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
|
||||
@@ -94,7 +94,7 @@ export default {server: _.merge(defaultConfig, envConfig), plex: plexConfig};
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
|
||||
@@ -73,7 +73,7 @@ export default plexConfig;
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
|
||||
@@ -70,7 +70,7 @@ export default testConfig;
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../prettify.js"></script>
|
||||
|
||||
@@ -76,7 +76,7 @@ export default server.create(config);
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../prettify.js"></script>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
|
||||
@@ -109,7 +109,7 @@ export default router;
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import express from 'express';
|
||||
import {json, urlencoded} from 'body-parser';
|
||||
import {sequelize} from './models';
|
||||
import {sequelize} from './db/models';
|
||||
import plex from './routes/plex.route';
|
||||
|
||||
export default () => {
|
||||
@@ -178,7 +178,7 @@ export default () => {
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file high" data-value="plexlibrary.js"><a href="plexlibrary.js.html">plexlibrary.js</a></td>
|
||||
<td class="file high" data-value="plexSection.js"><a href="plexSection.js.html">plexSection.js</a></td>
|
||||
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="5" class="abs high">5/5</td>
|
||||
@@ -88,7 +88,7 @@
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file high" data-value="plexsection.js"><a href="plexsection.js.html">plexsection.js</a></td>
|
||||
<td class="file high" data-value="plexlibrary.js"><a href="plexlibrary.js.html">plexlibrary.js</a></td>
|
||||
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="5" class="abs high">5/5</td>
|
||||
@@ -119,7 +119,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:47:15 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
|
||||
@@ -178,7 +178,7 @@ module.exports = db;
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:47:15 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:47:15 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for recommend/server/models/plexsection.js</title>
|
||||
<title>Code coverage report for recommend/server/models/plexSection.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../../base.css" />
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../../index.html">All files</a> / <a href="index.html">recommend/server/models</a> plexsection.js
|
||||
<a href="../../../index.html">All files</a> / <a href="index.html">recommend/server/models</a> plexSection.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
@@ -97,7 +97,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:47:15 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:47:15 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
|
||||
@@ -79,7 +79,7 @@ export default router;
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
|
||||
@@ -130,7 +130,7 @@ export default fetchToken;
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../../prettify.js"></script>
|
||||
|
||||
@@ -208,7 +208,7 @@ export default {formatResponse, buildUrl, request};
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../../prettify.js"></script>
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import plexApi from './plexApi';
|
||||
import models from '../../models';
|
||||
import models from '../../db/models';
|
||||
|
||||
const importSections = async () => {
|
||||
const sections = await plexApi.getSections();
|
||||
@@ -337,7 +337,7 @@ export default {importSections, importLibraries, importMostWatched};
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../../prettify.js"></script>
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../../prettify.js"></script>
|
||||
|
||||
@@ -244,7 +244,7 @@ export default {
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../../prettify.js"></script>
|
||||
|
||||
@@ -322,7 +322,7 @@ export default {
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 03:00:29 GMT-0600 (Central Standard Time)
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 12:58:57 GMT-0600 (Central Standard Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../../prettify.js"></script>
|
||||
|
||||
46
server/db/models/index.js
Normal file
46
server/db/models/index.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import Sequelize from 'sequelize';
|
||||
import configs from '../config/config';
|
||||
|
||||
const basename = path.basename(__filename);
|
||||
// istanbul ignore next
|
||||
const env = process.env.NODE_ENV || 'development';
|
||||
const config = configs[env];
|
||||
const capitalize = string => string[0].toUpperCase() + string.slice(1);
|
||||
|
||||
const sequelize = new Sequelize(
|
||||
config.database,
|
||||
config.username,
|
||||
config.password,
|
||||
{
|
||||
...config,
|
||||
operatorsAliases: false,
|
||||
logging: false,
|
||||
},
|
||||
);
|
||||
|
||||
const db = fs
|
||||
.readdirSync(__dirname)
|
||||
.filter(
|
||||
file =>
|
||||
file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js',
|
||||
)
|
||||
.reduce(
|
||||
(acc, file) => {
|
||||
const model = sequelize.import(path.join(__dirname, file));
|
||||
acc[capitalize(model.name)] = model;
|
||||
return acc;
|
||||
},
|
||||
{sequelize, Sequelize},
|
||||
);
|
||||
|
||||
Object.keys(db).forEach(modelName => {
|
||||
// istanbul ignore next
|
||||
if (db[modelName].associate) {
|
||||
db[modelName].associate(db);
|
||||
}
|
||||
});
|
||||
|
||||
// Syntax required to destructure models off of exported db
|
||||
module.exports = db;
|
||||
@@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import {json, urlencoded} from 'body-parser';
|
||||
import {sequelize} from './models';
|
||||
import {sequelize} from './db/models';
|
||||
import plex from './routes/plex.route';
|
||||
|
||||
export default () => {
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const Sequelize = require('sequelize');
|
||||
|
||||
const basename = path.basename(__filename);
|
||||
const env = process.env.NODE_ENV || 'development';
|
||||
const config = require(`${__dirname}/../../config/config.json`)[env];
|
||||
const db = {};
|
||||
|
||||
let sequelize;
|
||||
if (config.use_env_variable) {
|
||||
sequelize = new Sequelize(process.env[config.use_env_variable], config);
|
||||
} else {
|
||||
sequelize = new Sequelize(
|
||||
config.database,
|
||||
config.username,
|
||||
config.password,
|
||||
config,
|
||||
);
|
||||
}
|
||||
|
||||
fs.readdirSync(__dirname)
|
||||
.filter(file => {
|
||||
return (
|
||||
file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js'
|
||||
);
|
||||
})
|
||||
.forEach(file => {
|
||||
const model = sequelize.import(path.join(__dirname, file));
|
||||
db[model.name] = model;
|
||||
});
|
||||
|
||||
Object.keys(db).forEach(modelName => {
|
||||
if (db[modelName].associate) {
|
||||
db[modelName].associate(db);
|
||||
}
|
||||
});
|
||||
|
||||
db.sequelize = sequelize;
|
||||
db.Sequelize = Sequelize;
|
||||
|
||||
module.exports = db;
|
||||
@@ -1,5 +1,5 @@
|
||||
import plexApi from './plexApi';
|
||||
import models from '../../models';
|
||||
import models from '../../db/models';
|
||||
|
||||
const importSections = async () => {
|
||||
const sections = await plexApi.getSections();
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MediaContainer friendlyName="myPlex" identifier="com.plexapp.plugins.myplex" machineIdentifier="154b5ad3f3fade27a1f35eb8f44c014f7ab0d2a0" totalSize="6" size="6">
|
||||
<User id="22100504" title="e311connell@gmail.com" username="e311connell@gmail.com" email="e311connell@gmail.com" recommendationsPlaylistId="a3ab3b4756506985" thumb="https://plex.tv/users/1a12ace72ecebbff/avatar?c=1549164875" protected="0" home="0" allowSync="0" allowCameraUpload="0" allowChannels="0" allowTuners="0" allowSubtitleAdmin="0" filterAll="" filterMovies="" filterMusic="" filterPhotos="" filterTelevision="" restricted="0">
|
||||
<Server id="11520061" serverId="15932286" machineIdentifier="f1adbb16fead548bd0fd8dc723166dfa9ae6cd0a" name="mjrflix" lastSeenAt="1549854842" numLibraries="2" allLibraries="1" owned="1" pending="0"/>
|
||||
</User>
|
||||
<User id="22099864" title="mike.rode@malauzai.com" username="mike.rode@malauzai.com" email="mike.rode@malauzai.com" recommendationsPlaylistId="4f34e0b774a38c55" thumb="https://plex.tv/users/d269a00326accf58/avatar?c=1549783460" protected="0" home="0" allowSync="0" allowCameraUpload="0" allowChannels="0" allowTuners="0" allowSubtitleAdmin="0" filterAll="" filterMovies="" filterMusic="" filterPhotos="" filterTelevision="" restricted="0">
|
||||
<Server id="11519703" serverId="15932286" machineIdentifier="f1adbb16fead548bd0fd8dc723166dfa9ae6cd0a" name="mjrflix" lastSeenAt="1549854842" numLibraries="2" allLibraries="1" owned="1" pending="0"/>
|
||||
</User>
|
||||
<User id="22160998" title="mjrflix+carson@gmail.com" username="mjrflix+carson@gmail.com" email="mjrflix+carson@gmail.com" recommendationsPlaylistId="ffe32f53e19fad28" thumb="https://plex.tv/users/b70f48ce01d53a73/avatar?c=1549214882" protected="0" home="0" allowSync="0" allowCameraUpload="0" allowChannels="0" allowTuners="0" allowSubtitleAdmin="0" filterAll="" filterMovies="" filterMusic="" filterPhotos="" filterTelevision="" restricted="0">
|
||||
<Server id="11562729" serverId="15932286" machineIdentifier="f1adbb16fead548bd0fd8dc723166dfa9ae6cd0a" name="mjrflix" lastSeenAt="1549854842" numLibraries="2" allLibraries="1" owned="1" pending="0"/>
|
||||
</User>
|
||||
<User id="22160913" title="mjrflix+jazz@gmail.com" username="mjrflix+jazz@gmail.com" email="mjrflix+jazz@gmail.com" recommendationsPlaylistId="98a2337ca26c7420" thumb="https://plex.tv/users/df0eb846405fb1b6/avatar?c=1549214755" protected="0" home="0" allowSync="0" allowCameraUpload="0" allowChannels="0" allowTuners="0" allowSubtitleAdmin="0" filterAll="" filterMovies="" filterMusic="" filterPhotos="" filterTelevision="" restricted="0">
|
||||
<Server id="11562688" serverId="15932286" machineIdentifier="f1adbb16fead548bd0fd8dc723166dfa9ae6cd0a" name="mjrflix" lastSeenAt="1549854842" numLibraries="2" allLibraries="1" owned="1" pending="0"/>
|
||||
</User>
|
||||
<User id="22161020" title="mjrflix+wade@gmail.com" username="mjrflix+wade@gmail.com" email="mjrflix+wade@gmail.com" recommendationsPlaylistId="1d63c4534b40fd82" thumb="https://plex.tv/users/52e6cac0635b4f05/avatar?c=1549214823" protected="0" home="0" allowSync="0" allowCameraUpload="0" allowChannels="0" allowTuners="0" allowSubtitleAdmin="0" filterAll="" filterMovies="" filterMusic="" filterPhotos="" filterTelevision="" restricted="0">
|
||||
<Server id="11562742" serverId="15932286" machineIdentifier="f1adbb16fead548bd0fd8dc723166dfa9ae6cd0a" name="mjrflix" lastSeenAt="1549854842" numLibraries="2" allLibraries="1" owned="1" pending="0"/>
|
||||
</User>
|
||||
<User id="22110937" title="rode4@gmail.com" username="rode4@gmail.com" email="rode4@gmail.com" recommendationsPlaylistId="ccb87923782deff9" thumb="https://plex.tv/users/7c0d31791846bc6a/avatar?c=1548902067" protected="0" home="0" allowSync="0" allowCameraUpload="0" allowChannels="0" allowTuners="0" allowSubtitleAdmin="0" filterAll="" filterMovies="" filterMusic="" filterPhotos="" filterTelevision="" restricted="0">
|
||||
<Server id="11527625" serverId="15932286" machineIdentifier="f1adbb16fead548bd0fd8dc723166dfa9ae6cd0a" name="mjrflix" lastSeenAt="1549854842" numLibraries="2" allLibraries="1" owned="1" pending="0"/>
|
||||
</User>
|
||||
</MediaContainer>
|
||||
17
test/nocks.js
Normal file
17
test/nocks.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import nock from 'nock';
|
||||
import responses from './server/services/plex/mocks/plexResponses';
|
||||
|
||||
const plexSections = () => nock('https://plex.mjrflix.com')
|
||||
.get('/library/sections?X-Plex-Token=testPlexApiToken')
|
||||
.reply(200, responses.sections, {
|
||||
'Content-Type': 'text/json',
|
||||
});
|
||||
|
||||
const plexLibrary = () => nock('https://plex.mjrflix.com')
|
||||
.persist()
|
||||
.get(url => url.includes('/library/sections/'))
|
||||
.reply(200, responses.getLibraryDataBySectionRaw, {
|
||||
'Content-Type': 'text/json',
|
||||
});
|
||||
|
||||
export default { plexSections, plexLibrary };
|
||||
@@ -2,7 +2,7 @@ import chai from 'chai';
|
||||
import nock from 'nock';
|
||||
import app from '../../../../index';
|
||||
import responses from './mocks/plexResponses';
|
||||
import { PlexSection, User, PlexLibrary } from '../../../../server/models';
|
||||
import { PlexSection, User, PlexLibrary } from '../../../../server/db/models';
|
||||
import truncate from '../../../truncate';
|
||||
|
||||
// before(() => truncate('PlexSection'));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import models from '../server/models';
|
||||
import models from '../server/db/models';
|
||||
|
||||
const truncateTable = modelName => models[modelName].destroy({
|
||||
where: {},
|
||||
|
||||
Reference in New Issue
Block a user