Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
veganbeef committed Jan 28, 2025
1 parent 0d1042b commit 8443ded
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { DataSource } from 'typeorm';
import { env } from './env';

// Set default values for environment variables
const synchronize = env.SYNCHRONIZE?.toLowerCase() === 'true';
const logging = env.LOGGING?.toLowerCase() === 'true';
const synchronize = env.SYNCHRONIZE.toLowerCase() === 'true';
const logging = env.LOGGING.toLowerCase() === 'true';

export const AppDataSource = new DataSource({
type: 'postgres',
Expand Down
12 changes: 11 additions & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ interface EnvVars {
MAX_CONCURRENT_EVALUATIONS: number;
EVALUATION_BATCH_SIZE: number;
EVALUATION_BATCH_DELAY: number;
[key: string]: string | number | undefined; // Allow other env vars
DATABASE_URL: string;
SYNCHRONIZE: string;
LOGGING: string;
INDEXER_URL: string;
OPENAI_API_KEY: string;
[key: string]: string | number | undefined;
}

export const env: EnvVars = {
Expand All @@ -16,5 +21,10 @@ export const env: EnvVars = {
),
EVALUATION_BATCH_SIZE: Number(process.env.EVALUATION_BATCH_SIZE ?? 25),
EVALUATION_BATCH_DELAY: Number(process.env.EVALUATION_BATCH_DELAY ?? 2000),
DATABASE_URL: process.env.DATABASE_URL ?? '',
SYNCHRONIZE: process.env.SYNCHRONIZE ?? 'false',
LOGGING: process.env.LOGGING ?? 'false',
INDEXER_URL: process.env.INDEXER_URL ?? '',
OPENAI_API_KEY: process.env.OPENAI_API_KEY ?? '',
...process.env,
};
2 changes: 1 addition & 1 deletion src/ext/indexer/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import type { Logger } from 'winston';
import { IsNullError } from '@/errors';
import { env } from '@/env';
import { LRUCache } from 'lru-cache';
import LRUCache = require('lru-cache');

class IndexerClient {
private static instance: IndexerClient | null = null;
Expand Down
2 changes: 1 addition & 1 deletion src/ext/openai/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { type EvaluationSummaryInput } from '@/service/EvaluationService';
import { env } from '@/env';
import { parseArray, parseObject } from '@/utils';
import pLimit from 'p-limit';
import { LRUCache } from 'lru-cache';
import LRUCache = require('lru-cache');

const openai = new OpenAI({
apiKey: env.OPENAI_API_KEY,
Expand Down
4 changes: 1 addition & 3 deletions src/postgraphile.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { postgraphile } from 'postgraphile';
import ConnectionFilterPlugin from 'postgraphile-plugin-connection-filter';
import PgSimplifyInflectorPlugin from '@graphile-contrib/pg-simplify-inflector';

const DATABASE_URL = env.DATABASE_URL ?? '';

export const postgraphileMiddleware = postgraphile(DATABASE_URL, 'public', {
export const postgraphileMiddleware = postgraphile(env.DATABASE_URL, 'public', {
subscriptions: true,
watchPg: true,
dynamicJson: true,
Expand Down

0 comments on commit 8443ded

Please sign in to comment.