350 open graph react #360

Merged
bones7242 merged 30 commits from 350-open-graph-react into master 2018-02-24 17:55:00 +01:00
2 changed files with 61 additions and 44 deletions
Showing only changes of commit 701cc64062 - Show all commits

View file

@ -1,7 +1,7 @@
const fs = require('fs'); // const fs = require('fs');
const path = require('path'); // const path = require('path');
const Sequelize = require('sequelize'); const Sequelize = require('sequelize');
const basename = path.basename(module.filename); // const basename = path.basename(module.filename);
const logger = require('winston'); const logger = require('winston');
const config = require('../config/speechConfig.js'); const config = require('../config/speechConfig.js');
const { database, username, password } = config.sql; const { database, username, password } = config.sql;
@ -30,16 +30,30 @@ sequelize
logger.error('Sequelize was unable to connect to the database:', err); logger.error('Sequelize was unable to connect to the database:', err);
}); });
// add each model to the db object // // add each model to the db object
fs // fs
.readdirSync(__dirname) // .readdirSync(__dirname)
.filter(file => { // .filter(file => {
return (file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js'); // return (file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js');
}) // })
.forEach(file => { // .forEach(file => {
const model = sequelize['import'](path.join(__dirname, file)); // const model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model; // db[model.name] = model;
}); // });
// manually add each model to the db
const Certificate = require('./certificate.js');
const Channel = require('./channel.js');
const Claim = require('./claim.js');
const File = require('./file.js');
const Request = require('./request.js');
const User = require('./user.js');
db['Certificate'] = sequelize.import('Certificate', Certificate);
db['Channel'] = sequelize.import('Channel', Channel);
db['Claim'] = sequelize.import('Claim', Claim);
db['File'] = sequelize.import('File', File);
db['Request'] = sequelize.import('Request', Request);
db['User'] = sequelize.import('User', User);
// run model.association for each model in the db object that has an association // run model.association for each model in the db object that has an association
Object.keys(db).forEach(modelName => { Object.keys(db).forEach(modelName => {

View file

@ -5,38 +5,41 @@ const REACT_ROOT = Path.resolve(__dirname, 'react/');
console.log('REACT_ROOT:', REACT_ROOT); console.log('REACT_ROOT:', REACT_ROOT);
module.exports = [ module.exports = [
// { {
// target: 'web', target: 'web',
// entry : ['babel-polyfill', 'whatwg-fetch', './react/client.js'], entry : ['babel-polyfill', 'whatwg-fetch', './react/client.js'],
// output: { output: {
// path : Path.join(__dirname, 'public/bundle/'), path : Path.join(__dirname, 'public/bundle/'),
// publicPath: 'public/bundle/', publicPath: 'public/bundle/',
// filename : 'bundle.js', filename : 'bundle.js',
// }, },
// watch : true, watch : true,
// module: { module: {
// loaders: [ loaders: [
// { {
// test : /.jsx?$/, test : /.jsx?$/,
// loader : 'babel-loader', loader : 'babel-loader',
// exclude: /node_modules/, exclude: /node_modules/,
// query : { query : {
// presets: ['es2015', 'react', 'stage-2'], presets: ['es2015', 'react', 'stage-2'],
// }, },
// }, },
// ], ],
// }, },
// resolve: { resolve: {
// modules: [ modules: [
// REACT_ROOT, REACT_ROOT,
// 'node_modules', 'node_modules',
// __dirname, __dirname,
// ], ],
// extensions: ['.js', '.jsx', '.scss'], extensions: ['.js', '.jsx', '.scss'],
// }, },
// }, },
{ {
target: 'node', target: 'node',
node : {
__dirname: false,
},
externals: [nodeExternals()], externals: [nodeExternals()],
entry : ['./server.js'], entry : ['./server.js'],
output : { output : {