Skip to content

Commit

Permalink
nodes + go 重构完
Browse files Browse the repository at this point in the history
  • Loading branch information
刘珅 committed Apr 7, 2017
1 parent a1244ef commit c3a1555
Show file tree
Hide file tree
Showing 50 changed files with 42 additions and 81 deletions.
12 changes: 6 additions & 6 deletions configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"imagePath" : "/images",
"cssPath" : "/styles"
},
"env" : "development",
"useProxy" : true,
"port" : 8012
"env" : "development",
"useProxy" : true,
"port" : 8010,
"staticPort" : 8011
},
"go": {
"Debug" : true,
"URL" : "http://wemall.shen100.com",
"Port" : 8010,
"StaticPort" : 8011,
"Port" : 8012,
"MaxOrder" : 10000,
"MinOrder" : 0,
"PageSize" : 20,
Expand All @@ -48,7 +48,7 @@
"todayOrderCount": "/admin/order/todaycount",
"todayOrderSale": "/admin/order/todaysale",
"totalOrderCount": "/admin/order/totalcount",
"totalSale": "/admin/order/totalsale",
"totalSale": "/admin/order/totalsale"
},
"docs": {
"github": "https://xxx.com/shen100"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 12 additions & 1 deletion nginx/wemall.shen100.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
upstream wemallApp {
upstream wemallNodejs {
server 127.0.0.1:8010;
}

upstream wemallStaticServ {
server 127.0.0.1:8011;
}

upstream wemallApp {
server 127.0.0.1:8012;
}

server {
listen 80;
server_name wemall.shen100.com;
Expand All @@ -20,6 +24,13 @@ server {
#root /root/nowamagic_venv/nowamagic_pj;

location / {
proxy_pass http://wemallNodejs;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /api {
proxy_pass http://wemallApp;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions nodejs/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var config = {
env : configData.nodejs.env,
useProxy : configData.nodejs.useProxy,
port : configData.nodejs.port,
staticPort : configData.nodejs.staticPort,
page: {
title : configData.nodejs.page.title,
sitePath : configData.nodejs.page.sitePath,
Expand Down Expand Up @@ -40,3 +41,5 @@ var config = {
}
}
}())

module.exports = config;
8 changes: 8 additions & 0 deletions nodejs/helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var helpers = {
json: function(data) {
data = data || {};
return JSON.stringify(data);
}
};

module.exports = helpers;
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions staticServ.js → nodejs/staticServ.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');
var webpackConfig = require('./webpack.config');
var appConfig = require('./appconfig');
var config = require('./config');
var compiler = webpack(webpackConfig);

var app = express();
Expand Down Expand Up @@ -52,6 +52,6 @@ app.use(function(err, req, res, next) {
res.render('error');
});

server.listen(appConfig.server.StaticPort, function() {
console.log('StaticServ running at ' + appConfig.server.URL);
server.listen(config.staticPort, function() {
console.log('StaticServ running at :' + config.staticPort);
});
4 changes: 1 addition & 3 deletions nodejs/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ var EnvUtil = {
errors = errors.join('\n ');
console.error('\x1B[31mERROR: ' + packages.name + ' is unable to start due to missing dependencies:\x1B[0m\n ' + errors);
console.error('\x1B[32m\nPlease run `npm install` and try starting ' + packages.name + ' again.');
var github = config.docs.github;
var docStr = '\x1B[32mHelp and documentation can be found at ${github}\x1B[0m\n';
console.error(docStr);
console.error('\x1B[32mHelp and documentation can be found at ' + config.docs.github + '\x1B[0m\n');
return false;
}
};
Expand Down
14 changes: 9 additions & 5 deletions nodejs/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ var config = require('./config');
var hotMiddleware = 'webpack-hot-middleware/client?reload=true';
var jsPath = config.page.jsPath;

console.log(123456);


function getEntryMap() {
var entryArr = [
'admin/app'
];
var entryMap = {};
entryArr.forEach(function(key) {
entryMap[key] = ['babel-polyfill', '../static/javascripts/' + key + '.js', hotMiddleware];
entryMap[key] = ['babel-polyfill', './static/javascripts/' + key + '.js', hotMiddleware];
});

entryMap['vendor'] = [
'react',
'react-dom',
Expand All @@ -27,10 +31,10 @@ function getEntryMap() {
var config = {
entry: getEntryMap(),
output: {
publicPath : config.page.sitePath + '/',
filename : '.' + jsPath + '/[name].js',
publicPath : '/',
filename : './javascripts/[name].js',
path : path.resolve(__dirname, './dist/app/client'),
chunkFilename : '.' + jsPath + '/[name].js',
chunkFilename : './javascripts/[name].js'
},
module: {
loaders: [
Expand All @@ -52,7 +56,7 @@ var config = {
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: '.' + jsPath + '/vendor.bundle.js'
filename: './javascripts/vendor.bundle.js'
}),
new BellOnBundlerErrorPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
Expand Down
12 changes: 0 additions & 12 deletions server/views/404.hbs

This file was deleted.

37 changes: 0 additions & 37 deletions server/views/admin/index.hbs

This file was deleted.

14 changes: 0 additions & 14 deletions server/views/error.hbs

This file was deleted.

0 comments on commit c3a1555

Please sign in to comment.