You've already forked nginx-proxy-manager
							
							
				mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-11-04 04:11:42 +03:00 
			
		
		
		
	* Fix wrapping when too many hosts are shown (#207) * Update npm packages, fixes CVE-2019-10757 * Revert some breaking packages * Major overhaul - Docker buildx support in CI - Cypress API Testing in CI - Restructured folder layout (insert clean face meme) - Added Swagger documentation and validate API against that (to be completed) - Use common base image for all supported archs, which includes updated nginx with ipv6 support - Updated certbot and changes required for it - Large amount of Hosts names will wrap in UI - Updated packages for frontend - Version bump 2.1.0 * Updated documentation * Fix JWT expire time going crazy. Now set to 1day * Backend JS formatting rules * Remove v1 importer, I doubt anyone is using v1 anymore * Added backend formatting rules and enforce them in Jenkins builds * Fix CI, doesn't need a tty * Thanks bcrypt. Why can't you just be normal. * Cleanup after syntax check Co-authored-by: Marcelo Castagna <margaale@users.noreply.github.com>
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
let _ = require('lodash');
 | 
						|
 | 
						|
module.exports = function (default_sort, default_offset, default_limit, max_limit) {
 | 
						|
 | 
						|
	/**
 | 
						|
	 * This will setup the req query params with filtered data and defaults
 | 
						|
	 *
 | 
						|
	 * sort    will be an array of fields and their direction
 | 
						|
	 * offset  will be an int, defaulting to zero if no other default supplied
 | 
						|
	 * limit   will be an int, defaulting to 50 if no other default supplied, and limited to the max if that was supplied
 | 
						|
	 *
 | 
						|
	 */
 | 
						|
 | 
						|
	return function (req, res, next) {
 | 
						|
 | 
						|
		req.query.offset = typeof req.query.limit === 'undefined' ? default_offset || 0 : parseInt(req.query.offset, 10);
 | 
						|
		req.query.limit  = typeof req.query.limit === 'undefined' ? default_limit || 50 : parseInt(req.query.limit, 10);
 | 
						|
 | 
						|
		if (max_limit && req.query.limit > max_limit) {
 | 
						|
			req.query.limit = max_limit;
 | 
						|
		}
 | 
						|
 | 
						|
		// Sorting
 | 
						|
		let sort       = typeof req.query.sort === 'undefined' ? default_sort : req.query.sort;
 | 
						|
		let myRegexp   = /.*\.(asc|desc)$/ig;
 | 
						|
		let sort_array = [];
 | 
						|
 | 
						|
		sort = sort.split(',');
 | 
						|
		_.map(sort, function (val) {
 | 
						|
			let matches = myRegexp.exec(val);
 | 
						|
 | 
						|
			if (matches !== null) {
 | 
						|
				let dir = matches[1];
 | 
						|
				sort_array.push({
 | 
						|
					field: val.substr(0, val.length - (dir.length + 1)),
 | 
						|
					dir:   dir.toLowerCase()
 | 
						|
				});
 | 
						|
			} else {
 | 
						|
				sort_array.push({
 | 
						|
					field: val,
 | 
						|
					dir:   'asc'
 | 
						|
				});
 | 
						|
			}
 | 
						|
		});
 | 
						|
 | 
						|
		// Sort will now be in this format:
 | 
						|
		// [
 | 
						|
		//    { field: 'field1', dir: 'asc' },
 | 
						|
		//    { field: 'field2', dir: 'desc' }
 | 
						|
		// ]
 | 
						|
 | 
						|
		req.query.sort = sort_array;
 | 
						|
		next();
 | 
						|
	};
 | 
						|
};
 |