Skip to content

Commit 80d40d2

Browse files
committed
Misc fixes of the server
1 parent 161f1bd commit 80d40d2

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

docs/server.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ props:
5757
it is not async in NodeJS.
5858
- **`beforeRender`** — *Function* — Optional. The hook to be
5959
executed right before the generation of HTML template of the page. If given,
60+
it will receive the HTTP request as its only argument, and
6061
it should return a promise that resolves to an object with the following
6162
fields (all are optional):
6263
- **`config`** — *Object* — Config object to inject into the
@@ -66,5 +67,6 @@ props:
6667
- **`store`** — *Object* — Redux store which state will be
6768
injected into HTML template as the initial state of the app.
6869
- **`onExpressJsSetup`** — *Function* — Custom setup of ExpressJS
69-
server.
70+
server. Express server instance will be passed in as the only argument to this
71+
function.
7072
- **`port`** — *Number|String* — The port to be used by the server.

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"react-helmet": "^5.2.0",
2525
"react-redux": "^5.0.6",
2626
"react-router-dom": "^4.2.2",
27+
"redux": "^3.7.2",
2728
"request-ip": "^2.0.2",
2829
"serialize-javascript": "^1.4.0",
2930
"serve-favicon": "^2.4.5",
@@ -94,8 +95,8 @@
9495
"url": "git+https://github.com/topcoder-platform/topcoder-react-utils.git"
9596
},
9697
"scripts": {
97-
"build": "npm run clean && ./node_modules/.bin/webpack --env=production --colors --display-optimization-bailout --profile --progress && BABEL_END=production babel src/server --out-dir dist/server",
98-
"build:dev": "npm run clean && ./node_modules/.bin/webpack --env=development --bail --colors --display-optimization-bailout --profile --progress --watch && BABEL_ENV=development babel src/server --out-dir dist/server --watch",
98+
"build": "npm run clean && ./node_modules/.bin/webpack --env=production --colors --display-optimization-bailout --profile --progress && BABEL_END=production babel src --out-dir dist/server-side",
99+
"build:dev": "npm run clean && (./node_modules/.bin/webpack --env=development --bail --colors --display-optimization-bailout --profile --progress --watch | BABEL_ENV=development babel src --out-dir dist/server-side --watch)",
99100
"clean": "rm -rf dist",
100101
"jest": "jest --no-cache --maxWorkers=4 --config config/jest/default.js",
101102
"lint": "npm run lint:js && npm run lint:scss",

src/server/server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ export default async function factory(webpackConfig, options) {
2525
server.use(favicon(options.favicon));
2626
}
2727

28-
server.use(bodyParser.json());
28+
server.use(bodyParser.json({ limit: '300kb' }));
2929
server.use(bodyParser.urlencoded({ extended: false }));
3030
server.use(cookieParser());
3131
server.use(requestIp.mw());
3232

3333
loggerMiddleware.token('ip', req => req.clientIp);
3434
const FORMAT = ':ip > :status :method :url :response-time ms :res[content-length] :referrer :user-agent';
35-
server.use(loggerMiddleware(FORMAT), {
35+
server.use(loggerMiddleware(FORMAT, {
3636
stream: new stream.Writable({
3737
decodeStrings: false,
3838
write: (chunk, encoding, cb) => {
3939
options.logger.log(chunk);
4040
cb();
4141
},
4242
}),
43-
});
43+
}));
4444

4545
/* Setup of Hot Module Reloading for development environment.
4646
* These dependencies are not used, nor installed for production use,

0 commit comments

Comments
 (0)