Permalink
Browse files

utils.js

  • Loading branch information...
tj committed Dec 18, 2011
1 parent 0dfe616 commit f9612755ecfc4ad50dfe1a701271ab7ecb584ad2
Showing with 15 additions and 13 deletions.
  1. +13 −0 lib/utils.js
  2. +2 −13 routes.js
View
@@ -0,0 +1,13 @@
+
+var crypto = require('crypto');
+
+/**
+ * MD5 the given `str`.
+ */
+
+exports.md5 = function(str) {
+ return crypto
+ .createHash('md5')
+ .update(str)
+ .digest('hex');
+};
View
@@ -1,6 +1,6 @@
var rasterize = require('./lib/rasterize')
- , crypto = require('crypto')
+ , utils = require('./lib/utils')
, path = require('path')
, join = path.join
, fs = require('fs');
@@ -24,7 +24,7 @@ app.get('/', function(req, res, next){
app.get('/', function(req, res, next){
var url = req.query.url;
if (!url) return res.send(400);
- var id = md5(url);
+ var id = utils.md5(url);
var path = join(dir, id + '.png');
rasterize(url, path, function(err){
if (err) return next(err);
@@ -43,14 +43,3 @@ app.get('/stats', function(req, res){
res.send(obj);
});
});
-
-/**
- * MD5 the given `str`.
- */
-
-function md5(str) {
- return crypto
- .createHash('md5')
- .update(str)
- .digest('hex');
-}

0 comments on commit f961275

Please sign in to comment.