Folder structure #398

Merged
bones7242 merged 76 commits from folder-structure into master 2018-03-20 00:01:08 +01:00
12 changed files with 51 additions and 34 deletions
Showing only changes of commit 662e468df6 - Show all commits

6
config/lbryConfig.js Normal file
View file

@ -0,0 +1,6 @@
module.exports = {
api: {
apiHost: 'localhost',
apiPort: '5279',
},
};

View file

@ -1,4 +1,7 @@
module.exports = (winston, logLevel) => {
const logLevel = 'debug'; // options: silly, debug, verbose, info
module.exports = (winston) => {
// configure
winston.configure({
transports: [
new (winston.transports.Console)({
@ -11,7 +14,7 @@ module.exports = (winston, logLevel) => {
}),
],
});
// test all the log levels
winston.error('Level 0');
winston.warn('Level 1');
winston.info('Level 2');

View file

@ -3,7 +3,6 @@ module.exports = {
googleId: 'UA-60403362-6', // google id for analytics tracking; leave `null` if not applicable
},
logging: {
logLevel : 'debug', // options: silly, debug, verbose, info
slackWebHook : 'https://hooks.slack.com/services/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', // enter a webhook if you wish to push logs to slack; otherwise leave as `null`
slackErrorChannel: null, // enter a slack channel (#example) for errors to be sent to; otherwise leave null
slackInfoChannel : '#speech-dev1-errors', // enter a slack channel (#info) for info level logs to be sent to otherwise leave null
@ -31,13 +30,4 @@ module.exports = {
defaultThumbnail : 'https://spee.ch/assets/img/video_thumb_default.png',
defaultDescription: 'Open-source, decentralized image and video sharing.',
},
testing: {
testChannel : '@test', // a channel to make test publishes in
testChannelId : '3b5bc6b6819172c6e2f3f90aa855b14a956b4a82', // the claim id for the test channel
testChannelPassword: '1234', // password for the test channel
},
api: {
apiHost: 'localhost',
apiPort: '5279',
},
};

View file

@ -0,0 +1,5 @@
module.exports = {
testChannel : null, // a channel to make test publishes in
testChannelId : null, // the claim id for the test channel
testChannelPassword: null, // password for the test channel
};

5
config/testingConfig.js Normal file
View file

@ -0,0 +1,5 @@
module.exports = {
testChannel : '@test',
testChannelId : '3b5bc6b6819172c6e2f3f90aa855b14a956b4a82',
testChannelPassword: '1234',
};

View file

@ -1,6 +1,6 @@
const axios = require('axios');
const logger = require('winston');
const { api: { apiHost, apiPort } } = require('../config/speechConfig.js');
const { api: { apiHost, apiPort } } = require('../config/lbryConfig.js');
const lbryApiUri = 'http://' + apiHost + ':' + apiPort;
const { chooseGaLbrynetPublishLabel, sendGATimingEvent } = require('./googleAnalytics.js');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,19 +1,14 @@
// load dependencies
// app dependencies
const express = require('express');
const bodyParser = require('body-parser');
const expressHandlebars = require('express-handlebars');
const Handlebars = require('handlebars');
const { populateLocalsDotUser, serializeSpeechUser, deserializeSpeechUser } = require('./helpers/authHelpers.js');
const { logging: { logLevel } } = require('./config/speechConfig.js');
const logger = require('winston');
const helmet = require('helmet');
const app = express(); // create an Express application
const passport = require('passport');
const { populateLocalsDotUser, serializeSpeechUser, deserializeSpeechUser } = require('./helpers/authHelpers.js');
const cookieSession = require('cookie-session');
// configure logging
require('./config/loggerConfig.js')(logger, logLevel);
require('./config/slackConfig.js')(logger);
// logging dependencies
const logger = require('winston');
function SpeechServer (config) {
this.mysqlConfig = config.mysql;
@ -25,6 +20,18 @@ function SpeechServer (config) {
console.log(something);
};
this.start = () => {
this.configureLogging();
this.configureApp();
this.configureServer();
this.startServer();
};
this.configureLogging = () => {
require('./config/loggerConfig.js')(logger);
require('./config/slackConfig.js')(logger);
};
this.configureApp = () => {
const app = express(); // create an Express application
// trust the proxy to get ip address for us
app.enable('trust proxy');
@ -72,11 +79,13 @@ function SpeechServer (config) {
require('./routes/serve-routes.js')(app);
require('./routes/fallback-routes.js')(app);
const http = require('http');
const server = http.Server(app);
this.startServer(server);
this.app = app;
};
this.startServer = (server) => {
this.configureServer = () => {
const http = require('http');
this.server = http.Server(this.app);
};
this.startServer = () => {
// print config variables
require('./helpers/configVarCheck.js')(this.config);
this.db.sequelize
@ -84,7 +93,7 @@ function SpeechServer (config) {
.sync()
// start the server
.then(() => {
server.listen(this.PORT, () => {
this.server.listen(this.PORT, () => {
logger.info(`Server is listening on PORT ${this.PORT}`);
});
})

View file

@ -1,9 +1,8 @@
const chai = require('chai');
const expect = chai.expect;
const chaiHttp = require('chai-http');
const { site, testing } = require('../../config/speechConfig.js');
const { host } = site;
const { testChannel, testChannelId, testChannelPassword } = testing;
const { site: { host } } = require('../../config/speechConfig.js');
const { testChannel, testChannelId, testChannelPassword } = require('../../config/testingConfig.js');
const requestTimeout = 20000;
const publishTimeout = 120000;
const fs = require('fs');