Skip to content

Commit 52693d0

Browse files
committed
minor fixes
1 parent 686a6e7 commit 52693d0

4 files changed

Lines changed: 32 additions & 13 deletions

File tree

modules/config/index.js

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,56 @@
11
if (!process.env.NODE_ENV) {
22
process.env.NODE_ENV = 'development';
33
}
4+
45
Error.stackTraceLimit = 1000;
56

67
if (process.env.NODE_ENV == 'development' && process.env.DEV_TRACE) {
78
// @see https://github.com/AndreasMadsen/trace
89
// does not work now (buggy?)
910

10-
Error.stackTraceLimit = Infinity;
1111
require('trace'); // active long stack trace
12+
//require('clarify');
13+
14+
var csvPath = require('path').resolve(__dirname, 'worker-benchmark.csv');
15+
var out = require('fs').createWriteStream(csvPath);
16+
17+
setInterval(function() {
18+
var time = Date.now();
19+
var memo = process.memoryUsage();
20+
out.write(
21+
time + ',' +
22+
memo.rss + ', ' +
23+
memo.heapTotal + ', ' +
24+
memo.heapUsed + '\n'
25+
);
26+
}, 200);
1227
//require('clarify'); // Exclude node internal calls from the stack
1328
}
1429

1530
require('lib/debug');
1631

1732
var path = require('path');
1833
var fs = require('fs');
34+
var _ = require('lodash');
1935

2036
var secretDir = path.join(process.cwd(), '../secret');
2137

38+
module.exports = {
39+
"port": process.env.PORT || 3000,
40+
"host": process.env.HOST || '0.0.0.0',
41+
"siteHost": process.env.SITE_HOST || "",
42+
"staticHost": process.env.STATIC_HOST || ""
43+
};
44+
45+
2246
var secret;
2347
if (fs.existsSync(path.join(secretDir, 'secret.js'))) {
24-
secret = require(path.join(secretDir, 'secret'));
48+
secret = require(path.join(secretDir, 'secret'))(module.exports);
2549
} else {
2650
secret = require('./secret.template');
2751
}
2852

29-
module.exports = {
30-
"port": process.env.PORT || 3000,
31-
"host": process.env.HOST || '0.0.0.0',
32-
"siteHost": process.env.SITE_HOST || "",
33-
"staticHost": process.env.STATIC_HOST || "",
53+
_.assign(module.exports, {
3454
// "siteHost": "http://127.0.0.1:3000",
3555
"mongoose": {
3656
"uri": "mongodb://localhost/" + (process.env.NODE_ENV == 'test' ? "js_test" : "js"),
@@ -71,4 +91,4 @@ module.exports = {
7191
},
7292
projectRoot: process.cwd(),
7393
publicRoot: path.join(process.cwd(), 'public')
74-
};
94+
});

modules/setup/render.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const moment = require('moment');
4-
const Parser = require('jade').Parser;
54
const util = require('util');
65
const path = require('path');
76
const config = require('config');
@@ -36,7 +35,7 @@ function addStandardHelpers(locals, ctx) {
3635
// when I use a variable in jade, it's code analyzer (addWith, "with" module)
3736
// detects the variable and uses it in the wrapping function, effectively triggering it's evaluation
3837
// so I assign getter not to "csrf", but to "csrf.token", which will only be asked by "csrf.token", not a wrapper
39-
Object.defineProperty(locals, "csrf", {
38+
locals.csrf = {
4039
token: {
4140
get: function() {
4241
if (!ctx.req.user) {
@@ -51,7 +50,7 @@ function addStandardHelpers(locals, ctx) {
5150
return csrf;
5251
}
5352
}
54-
});
53+
};
5554

5655
// we don't use defer in sessions, so can assign it
5756
// (simpler, need to call yield this.session)

modules/setup/requestLog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = function(app) {
66
this.log = app.log.child({
77
reqId: this.reqId
88
});
9-
this.req.log = this.log; // passport.js strategy passes req around
9+
this.request.log = this.log; // passport.js strategy passes req around
1010

1111
yield next;
1212
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"path-to-regexp": "*",
9999
"prismjs": "git://github.com/LeaVerou/prism#gh-pages",
100100
"request": "*",
101-
"sanitize-html": "^1.3.0",
101+
"sanitize-html": "*",
102102
"send": "*",
103103
"stylus": "*",
104104
"svgutils": "*",

0 commit comments

Comments
 (0)