firebase-auth-cloudflare-workers
Version:
Zero-dependencies firebase auth library for Cloudflare Workers.
63 lines (62 loc) • 1.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiSettings = void 0;
/**
* Class that defines all the settings for the backend API endpoint.
*
* @param endpoint - The Firebase Auth backend endpoint.
* @param httpMethod - The http method for that endpoint.
* @constructor
*/
class ApiSettings {
version;
endpoint;
httpMethod;
requestValidator;
responseValidator;
constructor(version, endpoint, httpMethod = 'POST') {
this.version = version;
this.endpoint = endpoint;
this.httpMethod = httpMethod;
this.setRequestValidator(null).setResponseValidator(null);
}
/** @returns The backend API resource version. */
getVersion() {
return this.version;
}
/** @returns The backend API endpoint. */
getEndpoint() {
return this.endpoint;
}
/** @returns The request HTTP method. */
getHttpMethod() {
return this.httpMethod;
}
/**
* @param requestValidator - The request validator.
* @returns The current API settings instance.
*/
setRequestValidator(requestValidator) {
const nullFunction = () => undefined;
this.requestValidator = requestValidator || nullFunction;
return this;
}
/** @returns The request validator. */
getRequestValidator() {
return this.requestValidator;
}
/**
* @param responseValidator - The response validator.
* @returns The current API settings instance.
*/
setResponseValidator(responseValidator) {
const nullFunction = () => undefined;
this.responseValidator = responseValidator || nullFunction;
return this;
}
/** @returns The response validator. */
getResponseValidator() {
return this.responseValidator;
}
}
exports.ApiSettings = ApiSettings;