Skip to content

Commit d76d95c

Browse files
committed
Fix formatting
1 parent 4b7e8fa commit d76d95c

File tree

12 files changed

+975
-900
lines changed

12 files changed

+975
-900
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,5 @@
22
node_modules
33
npm-debug.log
44

5-
#project files of JetBrains IDEs
6-
.idea
7-
85
#Istanbul coverage folder
96
coverage

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- '0.10'
5-
- '0.12'
6-
- 'node'
4+
- '0.10'
5+
- '0.12'
6+
- 'node'
77
after_script:
8-
- npm run coveralls
8+
- npm run coveralls

example/fileServer.js

100755100644
Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,53 +24,61 @@
2424
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2525
*/
2626

27-
var fcgi = require('../index.js');
28-
var fs = require('fs');
29-
var util = require('util');
27+
'use strict';
28+
29+
var fcgi = require('../index.js'),
30+
fs = require('fs'),
31+
util = require('util');
3032

3133
var count = 0;
3234

3335
function s(obj) {
34-
return util.inspect(obj);
36+
return util.inspect(obj);
3537
}
3638

37-
fcgi.createServer(function(req, res) {
38-
count += 1;
39+
fcgi.createServer(function (req, res) {
40+
count += 1;
3941

40-
req.on('complete', function() {
41-
var path = req.url.slice(1);
42-
fs.stat(path, function(err, stat) {
43-
if (err) {
44-
res.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8', 'Content-Length': err.stack.length });
45-
res.end(err.stack + '\n');
46-
} else {
47-
var stream = fs.createReadStream(path);
48-
res.writeHead(200, { 'Content-Type': 'application/octet-stream', 'Content-Length': stat.size });
49-
stream.pipe(res);
50-
}
42+
req.on('complete', function () {
43+
var path = req.url.slice(1);
44+
fs.stat(path, function (err, stat) {
45+
if (err) {
46+
res.writeHead(500, {
47+
'Content-Type': 'text/plain; charset=utf-8',
48+
'Content-Length': err.stack.length
49+
});
50+
res.end(err.stack + '\n');
51+
} else {
52+
var stream = fs.createReadStream(path);
53+
res.writeHead(200, {
54+
'Content-Type': 'application/octet-stream',
55+
'Content-Length': stat.size
56+
});
57+
stream.pipe(res);
58+
}
59+
});
5160
});
52-
});
5361
}).listen();
5462

55-
process.on('uncaughtException', function(err) {
56-
fs.appendFileSync('test.log', err.stack + '\n\n');
57-
process.exit(1);
63+
process.on('uncaughtException', function (err) {
64+
fs.appendFileSync('test.log', err.stack + '\n\n');
65+
process.exit(1);
5866
});
5967

60-
process.on('exit', function() {
61-
fs.appendFileSync('test.log', 'Exit - Uptime:' + process.uptime() + '\n\n');
68+
process.on('exit', function () {
69+
fs.appendFileSync('test.log', 'Exit - Uptime:' + process.uptime() + '\n\n');
6270
});
6371

64-
process.on('SIGTERM', function() {
65-
fs.appendFileSync('test.log', 'SIGTERM\n');
66-
process.exit(0);
72+
process.on('SIGTERM', function () {
73+
fs.appendFileSync('test.log', 'SIGTERM\n');
74+
process.exit(0);
6775
});
6876

69-
process.on('SIGINT', function() {
70-
fs.appendFileSync('test.log', 'SIGINT\n');
71-
process.exit(0);
77+
process.on('SIGINT', function () {
78+
fs.appendFileSync('test.log', 'SIGINT\n');
79+
process.exit(0);
7280
});
7381

74-
process.on('SIGUSR1', function() {
75-
fs.appendFileSync('test.log', 'SIGUSR1\n');
82+
process.on('SIGUSR1', function () {
83+
fs.appendFileSync('test.log', 'SIGUSR1\n');
7684
});

example/integration.js

100755100644
Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -26,76 +26,76 @@
2626

2727
'use strict';
2828

29-
var path = require('path')
30-
, fcgiFramework = require('../index.js'); //this we want to test
29+
var path = require('path'),
30+
fcgiFramework = require('../index.js'); //this we want to test
3131

3232
var port = 8080;
3333
var socketPath = path.join(__dirname, 'echoServer');
3434
try {
35-
require('fs').unlinkSync(socketPath);
35+
require('fs').unlinkSync(socketPath);
3636
} catch (err) {
37-
//ignore if file doesn't exists
38-
if(err.code !== 'ENOENT') {
39-
throw err;
40-
}
37+
//ignore if file doesn't exists
38+
if (err.code !== 'ENOENT') {
39+
throw err;
40+
}
4141
}
4242

4343
function answerWithError(res, err) {
44-
res.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8', 'Content-Length': err.stack.length });
45-
res.end(err.stack + '\n');
44+
res.writeHead(500, {
45+
'Content-Type': 'text/plain; charset=utf-8',
46+
'Content-Length': err.stack.length + 1
47+
});
48+
49+
res.end(err.stack + '\n');
4650
}
4751

48-
fcgiFramework.createServer(
49-
function echo(req, res) {
52+
fcgiFramework.createServer(function echo(req, res) {
5053
var requestData;
5154

5255
req.on('data', function (data) {
53-
requestData = requestData + data;
56+
requestData = requestData + data;
5457
});
5558

5659
req.on('complete', function writeReqAsJson() {
57-
var echoData
58-
, size;
60+
var echoData, size;
5961

60-
try {
61-
var strippedRequest = require('lodash').omit(req, 'connection', 'buffer', 'socket', '_events', '_readableState', 'data');
62-
strippedRequest.data = requestData;
62+
try {
63+
var strippedRequest = require('lodash').omit(req, 'connection', 'buffer', 'socket', '_events', '_readableState', 'data');
64+
strippedRequest.data = requestData;
6365

64-
echoData = JSON.stringify(strippedRequest, null, 4); //hopefully only here will an error be thrown
65-
size = Buffer.byteLength(echoData, 'utf8');
66-
res.writeHead(
67-
200,
68-
{
69-
'Content-Type': 'application/json; charset=utf-8',
70-
'Content-Length': size
71-
}
72-
);
73-
res.end(echoData);
74-
} catch (err) {
75-
answerWithError(res, err);
76-
}
66+
echoData = JSON.stringify(strippedRequest, null, 4); //hopefully only here will an error be thrown
67+
size = Buffer.byteLength(echoData, 'utf8');
68+
res.writeHead(200, {
69+
'Content-Type': 'application/json; charset=utf-8',
70+
'Content-Length': size
71+
});
72+
res.end(echoData);
73+
} catch (err) {
74+
answerWithError(res, err);
75+
}
7776
});
7877

7978
req.on('error', answerWithError.bind(undefined, res));
80-
}
81-
).listen(socketPath, function cgiStarted(err) {
82-
console.log('cgi app listen on socket:' + socketPath);
83-
if (err) {
84-
throw err;
85-
} else {
86-
var http = require('http');
87-
var fcgiHandler = require('fcgi-handler');
79+
}).listen(socketPath, function cgiStarted(err) {
80+
console.log('cgi app listen on socket:' + socketPath);
81+
if (err) {
82+
throw err;
83+
} else {
84+
var http = require('http');
85+
var fcgiHandler = require('fcgi-handler');
8886

89-
var server = http.createServer(function (req, res) {
90-
fcgiHandler.connect({path: socketPath}, function (err, fcgiProcess) {
91-
if (err) {
92-
throw err;
93-
} else {
94-
//route all request to fcgi application
95-
fcgiProcess.handle(req, res, {/*empty Options*/});
96-
}
97-
});
98-
});
99-
server.listen(port);
100-
}
87+
var server = http.createServer(function (req, res) {
88+
fcgiHandler.connect({
89+
path: socketPath
90+
}, function (err, fcgiProcess) {
91+
if (err) {
92+
throw err;
93+
} else {
94+
//route all request to fcgi application
95+
fcgiProcess.handle(req, res, { /*empty Options*/ });
96+
}
97+
});
98+
});
99+
server.listen(port);
100+
}
101101
});

index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323
*/
2424

25+
'use strict';
26+
2527
var server = require('./lib/server.js');
2628
var response = require('./lib/response.js');
2729

@@ -46,14 +48,15 @@ exports.ServerResponse = exports.Response;
4648
* - config (optional): server configuration (default: { maxConns: 2000, maxReqs: 2000, multiplex: true, valueMap: {} })
4749
*/
4850

49-
exports.createServer = function(responder, authorizer, filter, config) {
50-
return new server.Server(responder, authorizer, filter, config);
51+
exports.createServer = function (responder, authorizer, filter, config) {
52+
return new server.Server(responder, authorizer, filter, config);
5153
};
5254

53-
exports.patchHttp = function() {
54-
var http = require('http');
55-
for (key in exports) {
56-
if (key in http)
57-
http[key] = exports[key];
58-
}
55+
exports.patchHttp = function () {
56+
var http = require('http');
57+
for (key in exports) {
58+
if (key in http) {
59+
http[key] = exports[key];
60+
}
61+
}
5962
};

0 commit comments

Comments
 (0)