image-classifier-ts
Version:
Command line tool to auto-classify images, renaming them with appropriate labels. Uses Node and Google Vision API.
35 lines • 1.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EnvironmentVariables = void 0;
var API_KEY_ENV_VAR = "IMAGE_CLASSIFIER_TS_API_KEY";
var GOOGLE_CRED_LOCATION_ENV_VAR = "GOOGLE_APPLICATION_CREDENTIALS";
var EnvironmentVariables;
(function (EnvironmentVariables) {
function validateOrThrow() {
if (!getGoogleCredentialsLocation()) {
throw new Error(getErrorMessage(GOOGLE_CRED_LOCATION_ENV_VAR));
}
getApiKeyOrThrow();
// note: Google's code seems to kick in as part of the process running,
// so an exception is also thrown from their code.
}
EnvironmentVariables.validateOrThrow = validateOrThrow;
function getErrorMessage(envVar) {
return "You need to set the environment variable '" + envVar + "' - please see the 'configure-google.md' readme.";
}
function getApiKeyOrThrow() {
var key = getApiKey();
if (key) {
return key;
}
throw new Error(getErrorMessage(API_KEY_ENV_VAR));
}
EnvironmentVariables.getApiKeyOrThrow = getApiKeyOrThrow;
function getGoogleCredentialsLocation() {
return process.env[GOOGLE_CRED_LOCATION_ENV_VAR];
}
function getApiKey() {
return process.env[API_KEY_ENV_VAR];
}
})(EnvironmentVariables = exports.EnvironmentVariables || (exports.EnvironmentVariables = {}));
//# sourceMappingURL=EnvironmentVariables.js.map