-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharc.js
40 lines (28 loc) · 949 Bytes
/
arc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* AutoReviewComments: http://stackapps.com/questions/2116/autoreviewcomments-pro-forma-comments-for-se */
var express = require('express');
var app = express();
var fs = require('fs');
var dataDir = './arcdata/';
var baseComments = dataDir + 'baseComments.json';
var arcRouter = express.Router();
console.log("Got " + arcRouter + " from " + express);
//arcRouter.use(function timeLog(req, res, next) {
// console.log("Time: " + Date.now() + " Request for " + req.originalUrl + " From " + req.ip);
// next();
//});
arcRouter.get('/', function(req, res, next) {
// asynchronous read the base comments.
fs.readFile(baseComments, 'utf8', function (err, data) {
if (err) {
return next(err);
}
var json;
try {
json = JSON.parse(data);
} catch (parserr) {
return next(parserr);
}
res.jsonp(json);
});
});
module.exports = arcRouter;