Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple Connect based NodeJS server to test the CORSAppender
Updated the CORSAppender to buffer messages before sending
- Loading branch information
Showing
5 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
LogJS Testing Server for NodeJS | ||
===== | ||
|
||
## What is this? | ||
|
||
A simple server for testing the CORS operation of the CORSAppender for LogJS. | ||
|
||
## How do I use this? | ||
|
||
In the `/server` folder, run the following: | ||
|
||
npm install connect | ||
npm install connect-xcors | ||
|
||
Then you can run this server. It is configured to listen for any connections from any | ||
origins at the moment. Not much of a concern because it's really just meant to be | ||
a simple test. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
var connect = require('connect'), | ||
http = require('http'), | ||
CORS = require('connect-xcors'), | ||
options = { | ||
methods: ['POST'] | ||
}, logRef = 1; | ||
|
||
var server = connect | ||
.createServer( | ||
connect.json(), | ||
CORS(options), | ||
function(req, res) { | ||
var buf = req.body; | ||
for (var idx = 0; idx < buf.length; idx++) { | ||
var msg = buf[idx], | ||
logMsg = '#' + logRef + ' [' + msg.t + '] ' + new Date(msg.ts).toString() + ': ' + msg.m; | ||
|
||
if (msg.u) { | ||
logMsg += ' (' + msg.u + ')'; | ||
} | ||
|
||
if (msg.l) { | ||
logMsg += ' @' + msg.l; | ||
} | ||
|
||
console.log(logMsg); | ||
logRef++; | ||
} | ||
res.writeHead(200, { 'Content-Type': 'text/plain'}); | ||
res.end('LogJS Server'); | ||
}).listen(3000); | ||
|