Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

switch from date-utils to cromagjs, eliminate monkey-patching

  • Loading branch information...
commit 70d460def9bdf15942c6cbe333baf56343486a4f 1 parent e3fa187
@JerrySievert authored
View
4 lib/plugins/clfloghandler.js
@@ -1,6 +1,6 @@
(function () {
var fs = require('fs');
- require('date-utils');
+ var Cromag = require('cromag');
var logfile;
@@ -12,7 +12,7 @@
exports.plugin = function (request, response, options) {
if (logfile) {
- var now = new Date();
+ var now = new Cromag();
var timestamp = now.toCLFString();
var referer = request.headers.referer ? request.headers.referer : "-";
View
4 lib/plugins/errorhandler.js
@@ -1,6 +1,6 @@
(function () {
var fs = require('fs');
- require('date-utils');
+ var Cromag = require('cromag');
var logfile;
@@ -11,7 +11,7 @@
};
exports.plugin = function (error) {
- var timestamp = new Date().toCLFString(),
+ var timestamp = new Cromag().toCLFString(),
entry = timestamp + ': ' + error;
if (logfile) {
View
8 lib/plugins/filehandler.js
@@ -4,7 +4,7 @@
url = require('url'),
mime = require('mime');
- require('date-utils');
+ var Cromag = require('cromag');
var base;
@@ -29,7 +29,7 @@
response.next();
} else {
if (request.headers['if-modified-since']) {
- var modified = Date.parse(request.headers['if-modified-since']);
+ var modified = Cromag.parse(request.headers['if-modified-since']);
if (modified && modified <= stats.mtime.valueOf()) {
response.statusCode(304);
@@ -45,10 +45,10 @@
response.next();
} else {
response.setHeader('Content-Type', mime.lookup(file));
- response.setHeader('Date', new Date().toUTCString());
+ response.setHeader('Date', new Cromag().toUTCString());
response.setHeader('Last-Modified', stats.mtime.toUTCString());
- response.setHeader('Age', parseInt((new Date().valueOf() - stats.mtime.valueOf()) / 1000));
+ response.setHeader('Age', parseInt((new Cromag().valueOf() - stats.mtime.valueOf()) / 1000));
if (options.timeout) {
response.setHeader('Cache-Control', 'max-age=' + options.timeout + ', public');
View
2  package.json
@@ -18,7 +18,7 @@
"dependencies": {
"cookies": "~0.1.6",
"mime": ">=1.2.2",
- "date-utils": ">1.0.0",
+ "cromag": ">0.1.0",
"optimist": ">=0.2",
"node-uuid": ">1.1.0",
"eventemitter2": ">=0.4.0"
View
4 server.js
@@ -1,10 +1,10 @@
-require('date-utils');
+var Cromag = require('cromag');
var app = require('./lib/appserver');
var appServer = new app.appserver();
-appServer.addRoute(/.+/, appServer.plugins.sessionhandler, { cookie: { expires: new Date().addYears(1), httpOnly: false } });
+appServer.addRoute(/.+/, appServer.plugins.sessionhandler, { cookie: { expires: new Cromag().addYears(1), httpOnly: false } });
appServer.addRoute(/.+/, appServer.plugins.filehandler, { basedir: '.' });
appServer.addRoute(/.+/, appServer.plugins.fourohfour);
var server = appServer.createServer();
Please sign in to comment.
Something went wrong with that request. Please try again.