removed webpack and started fixing relative routes
This commit is contained in:
parent
2847060144
commit
7ad111413c
20 changed files with 127 additions and 211 deletions
103
index.js
103
index.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,8 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const db = require('models');
|
const db = require('../models');
|
||||||
const lbryApi = require('helpers/lbryApi.js');
|
const lbryApi = require('../helpers/lbryApi.js');
|
||||||
const publishHelpers = require('helpers/publishHelpers.js');
|
const publishHelpers = require('../helpers/publishHelpers.js');
|
||||||
const { publishing: { primaryClaimAddress, additionalClaimAddresses } } = require('siteConfig.js');
|
const { publishing: { primaryClaimAddress, additionalClaimAddresses } } = require('../../config/siteConfig.js');
|
||||||
const Sequelize = require('sequelize');
|
const Sequelize = require('sequelize');
|
||||||
const Op = Sequelize.Op;
|
const Op = Sequelize.Op;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const db = require('models');
|
const db = require('../models');
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const { returnPaginatedChannelClaims } = require('helpers/channelPagination.js');
|
const { returnPaginatedChannelClaims } = require('../helpers/channelPagination.js');
|
||||||
|
|
||||||
const NO_CHANNEL = 'NO_CHANNEL';
|
const NO_CHANNEL = 'NO_CHANNEL';
|
||||||
const NO_CLAIM = 'NO_CLAIM';
|
const NO_CLAIM = 'NO_CLAIM';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const db = require('models');
|
const db = require('../models');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getRecentClaims () {
|
getRecentClaims () {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Reducers, GAListener, App, Sagas, Actions } from 'spee.ch-components';
|
||||||
*/
|
*/
|
||||||
import Helmet from 'react-helmet';
|
import Helmet from 'react-helmet';
|
||||||
|
|
||||||
const siteConfig = require('siteConfig.js');
|
const siteConfig = require('../../config/siteConfig.js');
|
||||||
|
|
||||||
const returnSagaWithParams = (saga, params) => {
|
const returnSagaWithParams = (saga, params) => {
|
||||||
return function * () {
|
return function * () {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const db = require('models');
|
const db = require('../models');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
postToStats (action, url, ipAddress, name, claimId, result) {
|
postToStats (action, url, ipAddress, name, claimId, result) {
|
||||||
|
|
101
server/index.js
101
server/index.js
|
@ -1,101 +0,0 @@
|
||||||
// app dependencies
|
|
||||||
const express = require('express');
|
|
||||||
const bodyParser = require('body-parser');
|
|
||||||
const expressHandlebars = require('express-handlebars');
|
|
||||||
const Handlebars = require('handlebars');
|
|
||||||
const helmet = require('helmet');
|
|
||||||
const cookieSession = require('cookie-session');
|
|
||||||
const http = require('http');
|
|
||||||
const logger = require('winston');
|
|
||||||
const requestLogger = require('middleware/requestLogger.js');
|
|
||||||
const Path = require('path');
|
|
||||||
const loggerConfig = require('loggerConfig.js');
|
|
||||||
const mysqlConfig = require('mysqlConfig.js');
|
|
||||||
const siteConfig = require('siteConfig.js');
|
|
||||||
const slackConfig = require('slackConfig.js');
|
|
||||||
|
|
||||||
function Server () {
|
|
||||||
this.configureLogger = loggerConfig.update(userConfig);
|
|
||||||
this.configureMysql = mysqlConfig.update(userConfig);
|
|
||||||
this.configureSite = siteConfig.update(userConfig);
|
|
||||||
this.configureSlack = slackConfig.update(userConfig);
|
|
||||||
this.createApp = () => {
|
|
||||||
// create an Express application
|
|
||||||
const app = express();
|
|
||||||
|
|
||||||
// trust the proxy to get ip address for us
|
|
||||||
app.enable('trust proxy');
|
|
||||||
|
|
||||||
/* add middleware */
|
|
||||||
// set HTTP headers to protect against well-known web vulnerabilties
|
|
||||||
app.use(helmet());
|
|
||||||
// 'express.static' to serve static files from public directory
|
|
||||||
if (siteConfig.routes.publicFolder) {
|
|
||||||
// take in a different public folder, so it can serve it's own bundle if needed
|
|
||||||
const publicFolder = Path.resolve(process.cwd(), siteConfig.routes.publicFolder);
|
|
||||||
app.use(express.static(publicFolder));
|
|
||||||
logger.info('serving static files from custom path:', publicFolder);
|
|
||||||
} else {
|
|
||||||
const publicPath = Path.resolve(process.cwd(), 'public');
|
|
||||||
app.use(express.static(publicPath));
|
|
||||||
logger.warn(`serving static files from default static path at ${publicPath}. Please specify a path in your config/siteConfig.js file`, );
|
|
||||||
};
|
|
||||||
// 'body parser' for parsing application/json
|
|
||||||
app.use(bodyParser.json());
|
|
||||||
// 'body parser' for parsing application/x-www-form-urlencoded
|
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
|
||||||
|
|
||||||
// add custom middleware (note: build out to accept dynamically use what is in server/middleware/
|
|
||||||
app.use(requestLogger);
|
|
||||||
|
|
||||||
// configure passport
|
|
||||||
const speechPassport = require('speechPassport');
|
|
||||||
// initialize passport
|
|
||||||
const sessionKey = siteConfig.auth.sessionKey;
|
|
||||||
app.use(cookieSession({
|
|
||||||
name : 'session',
|
|
||||||
keys : [sessionKey],
|
|
||||||
maxAge: 24 * 60 * 60 * 1000, // i.e. 24 hours
|
|
||||||
}));
|
|
||||||
app.use(speechPassport.initialize());
|
|
||||||
app.use(speechPassport.session());
|
|
||||||
|
|
||||||
// configure handlebars & register it with express app
|
|
||||||
const hbs = expressHandlebars.create({
|
|
||||||
defaultLayout: 'embed',
|
|
||||||
handlebars : Handlebars,
|
|
||||||
});
|
|
||||||
app.engine('handlebars', hbs.engine);
|
|
||||||
app.set('view engine', 'handlebars');
|
|
||||||
|
|
||||||
// set the routes on the app
|
|
||||||
require('./routes/auth/')(app);
|
|
||||||
require('./routes/api/')(app);
|
|
||||||
require('./routes/pages/')(app);
|
|
||||||
require('./routes/assets/')(app);
|
|
||||||
require('./routes/fallback/')(app);
|
|
||||||
|
|
||||||
this.app = app;
|
|
||||||
};
|
|
||||||
this.initialize = () => {
|
|
||||||
this.createApp();
|
|
||||||
this.server = http.Server(this.app);
|
|
||||||
};
|
|
||||||
this.start = () => {
|
|
||||||
const db = require('models');
|
|
||||||
const PORT = siteConfig.details.port;
|
|
||||||
// sync sequelize
|
|
||||||
db.sequelize.sync()
|
|
||||||
// start the server
|
|
||||||
.then(() => {
|
|
||||||
this.server.listen(PORT, () => {
|
|
||||||
logger.info(`Server is listening on PORT ${PORT}`);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
logger.error(`Startup Error:`, error);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Server;
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { getChannelClaims } = require('controllers/serveController.js');
|
const { getChannelClaims } = require('../../controllers/serveController.js');
|
||||||
const { handleErrorResponse } = require('helpers/errorHandlers.js');
|
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
|
||||||
|
|
||||||
const NO_CHANNEL = 'NO_CHANNEL';
|
const NO_CHANNEL = 'NO_CHANNEL';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { handleErrorResponse } = require('helpers/errorHandlers.js');
|
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
|
||||||
const db = require('models');
|
const db = require('../../models');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { claimNameIsAvailable } = require('controllers/publishController.js');
|
const { claimNameIsAvailable } = require('../../controllers/publishController.js');
|
||||||
const { sendGATimingEvent } = require('helpers/googleAnalytics.js');
|
const { sendGATimingEvent } = require('../../helpers/googleAnalytics.js');
|
||||||
const { handleErrorResponse } = require('helpers/errorHandlers.js');
|
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const { getClaim } = require('helpers/lbryApi.js');
|
const { getClaim } = require('../../helpers/lbryApi.js');
|
||||||
const { addGetResultsToFileData, createFileData } = require('../../helpers/publishHelpers.js');
|
const { addGetResultsToFileData, createFileData } = require('../../helpers/publishHelpers.js');
|
||||||
const { handleErrorResponse } = require('helpers/errorHandlers.js');
|
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
|
||||||
const db = require('models');
|
const db = require('../../models');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { getClaimList } = require('helpers/lbryApi.js');
|
const { getClaimList } = require('../../helpers/lbryApi.js');
|
||||||
const { handleErrorResponse } = require('helpers/errorHandlers.js');
|
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { handleErrorResponse } = require('helpers/errorHandlers.js');
|
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
|
||||||
const db = require('models');
|
const db = require('../../models');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const speechPassport = require('speechPassport');
|
const speechPassport = require('../speechPassport');
|
||||||
const handleSignupRequest = require('./signup');
|
const handleSignupRequest = require('./signup');
|
||||||
const handleLoginRequest = require('./login');
|
const handleLoginRequest = require('./login');
|
||||||
const handleLogoutRequest = require('./logout');
|
const handleLogoutRequest = require('./logout');
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// load dependencies
|
// load dependencies
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const db = require('models');
|
const db = require('../models');
|
||||||
// configure logging
|
// configure logging
|
||||||
require('helpers/configureLogger.js')(logger);
|
require('../helpers/configureLogger.js')(logger);
|
||||||
|
|
||||||
const userName = process.argv[2];
|
const userName = process.argv[2];
|
||||||
logger.debug('user name:', userName);
|
logger.debug('user name:', userName);
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
const packageBaseConfig = require('./webpack.speech.common.js');
|
|
||||||
|
|
||||||
module.exports = [
|
|
||||||
packageBaseConfig,
|
|
||||||
];
|
|
|
@ -1,11 +0,0 @@
|
||||||
const packageBaseConfig = require('./webpack.speech.common.js');
|
|
||||||
const merge = require('webpack-merge');
|
|
||||||
|
|
||||||
const devBuildConfig = {
|
|
||||||
watch : true,
|
|
||||||
devtool: 'inline-source-map',
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = [
|
|
||||||
merge(packageBaseConfig, devBuildConfig),
|
|
||||||
];
|
|
|
@ -1,20 +0,0 @@
|
||||||
const webpack = require('webpack');
|
|
||||||
const merge = require('webpack-merge');
|
|
||||||
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
|
||||||
const packageBaseConfig = require('./webpack.speech.common.js');
|
|
||||||
|
|
||||||
const productionBuildConfig = {
|
|
||||||
devtool: 'source-map',
|
|
||||||
plugins: [
|
|
||||||
new UglifyJSPlugin({
|
|
||||||
sourceMap: true,
|
|
||||||
}),
|
|
||||||
new webpack.DefinePlugin({
|
|
||||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = [
|
|
||||||
merge(packageBaseConfig, productionBuildConfig),
|
|
||||||
];
|
|
|
@ -1,45 +0,0 @@
|
||||||
const Path = require('path');
|
|
||||||
const nodeExternals = require('webpack-node-externals');
|
|
||||||
const CONFIG_ROOT = Path.resolve(__dirname, 'config/');
|
|
||||||
const SERVER_ROOT = Path.resolve(__dirname, 'server/');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
target: 'node',
|
|
||||||
node : {
|
|
||||||
__dirname: false,
|
|
||||||
},
|
|
||||||
externals: [nodeExternals()],
|
|
||||||
entry : ['babel-polyfill', 'whatwg-fetch', './server/index.js'],
|
|
||||||
output : {
|
|
||||||
path : Path.join(__dirname, '/'),
|
|
||||||
publicPath : '/',
|
|
||||||
filename : 'index.js',
|
|
||||||
library : '',
|
|
||||||
libraryTarget: 'commonjs-module',
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test : /.jsx?$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
loader : 'babel-loader',
|
|
||||||
options: {
|
|
||||||
presets: ['es2015', 'react', 'stage-2'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test : /.css$/,
|
|
||||||
loader: 'css-loader',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
modules: [
|
|
||||||
CONFIG_ROOT,
|
|
||||||
SERVER_ROOT,
|
|
||||||
'node_modules',
|
|
||||||
__dirname,
|
|
||||||
],
|
|
||||||
extensions: ['.js', '.json', '.jsx', '.css'],
|
|
||||||
},
|
|
||||||
};
|
|
Loading…
Reference in a new issue