Skip to content

Commit

Permalink
feat: add clickhouse endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Jan 26, 2024
1 parent 4ba2364 commit e8ef9a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/api/src/routes/internal/gpt/clickhouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const post: Handler = async (req, res) => {
}

try {
const client = createClickhouseClient();
const client = createClickhouseClient('gpt', 'gpt');
const rows = await client.query({
clickhouse_settings: {
add_http_cors_header: 1,
Expand Down
8 changes: 6 additions & 2 deletions apps/api/src/utils/createClickhouseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import { createClient } from '@clickhouse/client';

import { CLICKHOUSE_URL } from './constants';

const createClickhouseClient = () => {
const createClickhouseClient = (username?: string, password?: string) => {
password = password || process.env.CLICKHOUSE_PASSWORD;
username = username || 'default';

return createClient({
database: 'default',
host: CLICKHOUSE_URL,
password: process.env.CLICKHOUSE_PASSWORD
password,
username
});
};

Expand Down

0 comments on commit e8ef9a2

Please sign in to comment.