mirror of
				https://git.sleeping.town/mirrors/foxy-moxy
				synced 2025-11-03 10:02:34 -08:00 
			
		
		
		
	Remove abuse-prone endpoints.
This commit is contained in:
		
							parent
							
								
									4d648a288f
								
							
						
					
					
						commit
						3c7c7938f3
					
				
					 1 changed files with 1 additions and 22 deletions
				
			
		
							
								
								
									
										23
									
								
								server.js
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								server.js
									
										
									
									
									
								
							| 
						 | 
					@ -48,34 +48,13 @@ app.use(express.static(__dirname + '/images'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var cacheTimeout = 60 * 60 * 24 * 30;
 | 
					var cacheTimeout = 60 * 60 * 24 * 30;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.get('/', function(req, res) {
 | 
					 | 
				
			||||||
    var width = 400;
 | 
					 | 
				
			||||||
    var seed = uuid();
 | 
					 | 
				
			||||||
    var canvas = composeImage(width, width, seed);
 | 
					 | 
				
			||||||
    var buffer = canvas.toBuffer();
 | 
					 | 
				
			||||||
    res.set('Cache-Control', 'max-age=' + cacheTimeout);
 | 
					 | 
				
			||||||
    res.set('Content-length', buffer.length);
 | 
					 | 
				
			||||||
    res.type('png');
 | 
					 | 
				
			||||||
    res.end(buffer, 'binary');
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
app.get('/healthcheck', function(req, res) {
 | 
					app.get('/healthcheck', function(req, res) {
 | 
				
			||||||
  res.status(200).end();
 | 
					  res.status(200).end();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.get('/:width', function(req, res) {
 | 
					 | 
				
			||||||
    var width = parseInt(req.params.width) || 400;
 | 
					 | 
				
			||||||
    var seed = uuid();
 | 
					 | 
				
			||||||
    var canvas = composeImage(width, width, seed);
 | 
					 | 
				
			||||||
    var buffer = canvas.toBuffer();
 | 
					 | 
				
			||||||
    res.set('Cache-Control', 'max-age=' + cacheTimeout);
 | 
					 | 
				
			||||||
    res.set('Content-length', buffer.length);
 | 
					 | 
				
			||||||
    res.type('png');
 | 
					 | 
				
			||||||
    res.end(buffer, 'binary');
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
app.get('/:width/:seed', function(req, res) {
 | 
					app.get('/:width/:seed', function(req, res) {
 | 
				
			||||||
    var width = parseInt(req.params.width) || 400;
 | 
					    var width = parseInt(req.params.width) || 400;
 | 
				
			||||||
 | 
					    if (width > 400) width = 400;
 | 
				
			||||||
    var seed = sanitize(req.params.seed) || uuid();
 | 
					    var seed = sanitize(req.params.seed) || uuid();
 | 
				
			||||||
    var canvas = composeImage(width, width, seed);
 | 
					    var canvas = composeImage(width, width, seed);
 | 
				
			||||||
    var buffer = canvas.toBuffer();
 | 
					    var buffer = canvas.toBuffer();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue