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 
			
		
		
		
	Introducing the Setup Wizard for creating the first user
- no longer setup a default - still able to do that with env vars however
This commit is contained in:
		| @@ -14,30 +14,27 @@ const ajv = new Ajv({ | ||||
|  * @param {Object} payload | ||||
|  * @returns {Promise} | ||||
|  */ | ||||
| function apiValidator(schema, payload /*, description*/) { | ||||
| 	return new Promise(function Promise_apiValidator(resolve, reject) { | ||||
| 		if (schema === null) { | ||||
| 			reject(new errs.ValidationError("Schema is undefined")); | ||||
| 			return; | ||||
| 		} | ||||
| const apiValidator = async (schema, payload /*, description*/) => { | ||||
| 	if (!schema) { | ||||
| 		throw new errs.ValidationError("Schema is undefined"); | ||||
| 	} | ||||
|  | ||||
| 		if (typeof payload === "undefined") { | ||||
| 			reject(new errs.ValidationError("Payload is undefined")); | ||||
| 			return; | ||||
| 		} | ||||
| 	// Can't use falsy check here as valid payload could be `0` or `false` | ||||
| 	if (typeof payload === "undefined") { | ||||
| 		throw new errs.ValidationError("Payload is undefined"); | ||||
| 	} | ||||
|  | ||||
| 		const validate = ajv.compile(schema); | ||||
| 		const valid = validate(payload); | ||||
| 	const validate = ajv.compile(schema); | ||||
| 	const valid = validate(payload); | ||||
|  | ||||
| 		if (valid && !validate.errors) { | ||||
| 			resolve(payload); | ||||
| 		} else { | ||||
| 			const message = ajv.errorsText(validate.errors); | ||||
| 			const err = new errs.ValidationError(message); | ||||
| 			err.debug = [validate.errors, payload]; | ||||
| 			reject(err); | ||||
| 		} | ||||
| 	}); | ||||
| } | ||||
| 	if (valid && !validate.errors) { | ||||
| 		return payload; | ||||
| 	} | ||||
|  | ||||
| 	const message = ajv.errorsText(validate.errors); | ||||
| 	const err = new errs.ValidationError(message); | ||||
| 	err.debug = [validate.errors, payload]; | ||||
| 	throw err; | ||||
| }; | ||||
|  | ||||
| export default apiValidator; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user