mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-11-04 09:25:15 +00:00 
			
		
		
		
	- /schema now returns full openapi/swagger schema - That schema is used to validate incoming requests - And used as a contract in future integration tests - Moved route files up one level - Fixed incorrect 404 reponses when getting objects - Fixed saving new objects and passing jsonschemavalidation
		
			
				
	
	
		
			39 lines
		
	
	
		
			900 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			900 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const express = require('express');
 | 
						|
const schema  = require('../schema');
 | 
						|
const PACKAGE = require('../package.json');
 | 
						|
 | 
						|
const router = express.Router({
 | 
						|
	caseSensitive: true,
 | 
						|
	strict:        true,
 | 
						|
	mergeParams:   true
 | 
						|
});
 | 
						|
 | 
						|
router
 | 
						|
	.route('/')
 | 
						|
	.options((_, res) => {
 | 
						|
		res.sendStatus(204);
 | 
						|
	})
 | 
						|
 | 
						|
	/**
 | 
						|
	 * GET /schema
 | 
						|
	 */
 | 
						|
	.get(async (req, res) => {
 | 
						|
		let swaggerJSON = await schema.getCompiledSchema();
 | 
						|
 | 
						|
		let proto = req.protocol;
 | 
						|
		if (typeof req.headers['x-forwarded-proto'] !== 'undefined' && req.headers['x-forwarded-proto']) {
 | 
						|
			proto = req.headers['x-forwarded-proto'];
 | 
						|
		}
 | 
						|
 | 
						|
		let origin = proto + '://' + req.hostname;
 | 
						|
		if (typeof req.headers.origin !== 'undefined' && req.headers.origin) {
 | 
						|
			origin = req.headers.origin;
 | 
						|
		}
 | 
						|
 | 
						|
		swaggerJSON.info.version   = PACKAGE.version;
 | 
						|
		swaggerJSON.servers[0].url = origin + '/api';
 | 
						|
		res.status(200).send(swaggerJSON);
 | 
						|
	});
 | 
						|
 | 
						|
module.exports = router;
 |