Skip to content

Commit

Permalink
vision changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BurhanCantCode committed Aug 3, 2024
1 parent 4988b1c commit bd479a9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions utils/visionUtils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import vision from '@google-cloud/vision';

let client: any;
let client: vision.ImageAnnotatorClient;

try {
const clientEmail = process.env.EMAIL;
const privateKey = process.env.PRIVATE_KEY?.replace(/\\n/g, '\n');

if (!clientEmail || !privateKey) {
throw new Error('Missing required environment variables for Google Cloud credentials');
}

const credentials = {
client_email: process.env.EMAIL,
private_key: process.env.PRIVATE_KEY.replace(/\\n/g, '\n'),
client_email: clientEmail,
private_key: privateKey,
};

client = new vision.ImageAnnotatorClient({ credentials });
} catch (error) {
console.error('Error parsing Google Cloud credentials:', error);
Expand Down

0 comments on commit bd479a9

Please sign in to comment.