You've already forked nginx-proxy-manager
							
							
				mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-10-30 18:05:34 +03:00 
			
		
		
		
	Convert backend to ESM
- About 5 years overdue - Remove eslint, use bomejs instead
This commit is contained in:
		| @@ -1,12 +1,12 @@ | ||||
| const Ajv   = require('ajv/dist/2020'); | ||||
| const error = require('../error'); | ||||
| import Ajv from "ajv/dist/2020.js"; | ||||
| import errs from "../error.js"; | ||||
|  | ||||
| const ajv = new Ajv({ | ||||
| 	verbose:         true, | ||||
| 	allErrors:       true, | ||||
| 	verbose: true, | ||||
| 	allErrors: true, | ||||
| 	allowUnionTypes: true, | ||||
| 	strict:          false, | ||||
| 	coerceTypes:     true, | ||||
| 	strict: false, | ||||
| 	coerceTypes: true, | ||||
| }); | ||||
|  | ||||
| /** | ||||
| @@ -14,30 +14,30 @@ const ajv = new Ajv({ | ||||
|  * @param {Object} payload | ||||
|  * @returns {Promise} | ||||
|  */ | ||||
| function apiValidator (schema, payload/*, description*/) { | ||||
| 	return new Promise(function Promise_apiValidator (resolve, reject) { | ||||
| function apiValidator(schema, payload /*, description*/) { | ||||
| 	return new Promise(function Promise_apiValidator(resolve, reject) { | ||||
| 		if (schema === null) { | ||||
| 			reject(new error.ValidationError('Schema is undefined')); | ||||
| 			reject(new errs.ValidationError("Schema is undefined")); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		if (typeof payload === 'undefined') { | ||||
| 			reject(new error.ValidationError('Payload is undefined')); | ||||
| 		if (typeof payload === "undefined") { | ||||
| 			reject(new errs.ValidationError("Payload is undefined")); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		const validate = ajv.compile(schema); | ||||
| 		const valid    = validate(payload); | ||||
| 		const valid = validate(payload); | ||||
|  | ||||
| 		if (valid && !validate.errors) { | ||||
| 			resolve(payload); | ||||
| 		} else { | ||||
| 			let message = ajv.errorsText(validate.errors); | ||||
| 			let err     = new error.ValidationError(message); | ||||
| 			err.debug   = [validate.errors, payload]; | ||||
| 			const message = ajv.errorsText(validate.errors); | ||||
| 			const err = new errs.ValidationError(message); | ||||
| 			err.debug = [validate.errors, payload]; | ||||
| 			reject(err); | ||||
| 		} | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| module.exports = apiValidator; | ||||
| export default apiValidator; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user