Skip to content

Commit

Permalink
patch setup file for prisma commands during dev
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycarambat committed Jan 10, 2024
1 parent 3381eb8 commit 0bfa64f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
18 changes: 12 additions & 6 deletions backend/utils/vectordatabases/providers/chroma/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,36 @@ class Chroma {

// For use with ChromaClient SDK only.
#appendClientAuthHeaders() {
const { settings } = this.config
const { settings } = this.config;
if (!settings?.authToken) return {};

const headerName = settings.authTokenHeader || "X-Api-Key";
const authToken = headerName === 'Authorization' ? `Bearer ${settings.authToken}` : settings.authToken
const authToken =
headerName === "Authorization"
? `Bearer ${settings.authToken}`
: settings.authToken;
return {
fetchOptions: {
headers: {
[headerName]: authToken,
},
},
}
};
}

// For use with fetch API endpoints only.
#appendRawAuthHeaders() {
const { settings } = this.config
const { settings } = this.config;
if (!settings?.authToken) return {};

const headerName = settings.authTokenHeader || "X-Api-Key";
const authToken = headerName === 'Authorization' ? `Bearer ${settings.authToken}` : settings.authToken
const authToken =
headerName === "Authorization"
? `Bearer ${settings.authToken}`
: settings.authToken;
return {
[headerName]: authToken,
}
};
}

setConfig(config) {
Expand Down
11 changes: 8 additions & 3 deletions devSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ const fs = require('fs');
const path = require('path');

const serverEnvTemplate = path.resolve(__dirname, 'backend/.env.example');
const serverEnv = path.resolve(__dirname, 'backend/.env.development')
const serverDevEnv = path.resolve(__dirname, 'backend/.env.development')
const serverEnv = path.resolve(__dirname, 'backend/.env')

const frontendEnvTemplate = path.resolve(__dirname, 'frontend/.env.example');
const frontendEnv = path.resolve(__dirname, 'frontend/.env')
const workerEnvTemplate = path.resolve(__dirname, 'workers/.env.example');
const workerEnv = path.resolve(__dirname, 'workers/.env')

if (!fs.existsSync(serverEnv)) {
console.log("Copying server env file template.");
if (!fs.existsSync(serverEnv) || !fs.existsSync(serverDevEnv)) {
console.log("Copying server env & env.development file template.");
fs.writeFileSync(serverDevEnv, '');
fs.writeFileSync(serverEnv, '');

fs.copyFileSync(serverEnvTemplate, serverDevEnv);
fs.copyFileSync(serverEnvTemplate, serverEnv);
console.log("Server env file created.");
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const API_BASE = import.meta.env.VITE_API_BASE || "/api";
export const API_BASE = import.meta.env.VITE_API_BASE || '/api';
export const APP_NAME = import.meta.env.VITE_APP_NAME || 'VDMS';
export const STORE_USER = 'vdms_user';
export const STORE_TOKEN = 'vdms_authToken';
Expand Down

0 comments on commit 0bfa64f

Please sign in to comment.