This commit is contained in:
jomo 2014-10-19 23:32:13 +02:00
commit adea3320bc
4 changed files with 73 additions and 69 deletions

4
app.js
View File

@ -14,8 +14,7 @@ var app = express();
app.set('views', path.join(__dirname, 'views')); app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade'); app.set('view engine', 'jade');
// uncomment after placing your favicon in /public app.use(favicon(__dirname + '/public/favicon.ico'));
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev')); app.use(logger('dev'));
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.urlencoded({ extended: false }));
@ -25,6 +24,7 @@ app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes); app.use('/', routes);
app.use('/avatars', avatars); app.use('/avatars', avatars);
// catch 404 and forward to error handler // catch 404 and forward to error handler
app.use(function(req, res, next) { app.use(function(req, res, next) {
var err = new Error('Not Found'); var err = new Error('Not Found');

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -9,6 +9,10 @@ var valid_uuid = /^[0-9a-f]{32}$/;
router.get('/:uuid/:size?', function(req, res) { router.get('/:uuid/:size?', function(req, res) {
var uuid = req.param('uuid'); var uuid = req.param('uuid');
var size = req.param('size') || 180; var size = req.param('size') || 180;
// Add temporary restriction to prevent app from crashing
if (size <= 0) {
size = 180;
}
console.log(uuid); console.log(uuid);
if (valid_uuid.test(uuid)) { if (valid_uuid.test(uuid)) {
var filename = uuid + ".png"; var filename = uuid + ".png";