Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/dbagent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"kysely": "^0.27.5",
"lucide-react": "^0.476.0",
"next": "^15.1.7",
"next-auth": "5.0.0-beta.25",
"next-themes": "^0.4.4",
"pg": "^8.13.3",
"react": "19.0.0",
Expand Down
2 changes: 2 additions & 0 deletions apps/dbagent/src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { handlers } from '~/auth';
export const { GET, POST } = handlers;
21 changes: 21 additions & 0 deletions apps/dbagent/src/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import NextAuth from 'next-auth';
import { env } from './lib/env/server';

export const { handlers, signIn, signOut, auth } = NextAuth({
providers: [
{
id: 'openid',
name: 'OpenID',
type: 'oidc',
options: {
clientId: env.AUTH_OPENID_ID,
clientSecret: env.AUTH_OPENID_SECRET,
issuer: env.AUTH_OPENID_ISSUER
}
}
],
secret: env.AUTH_SECRET,
session: {
strategy: 'jwt'
}
});
2 changes: 1 addition & 1 deletion apps/dbagent/src/lib/db/db.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';
import { env } from '../env/db';
import { env } from '../env/server';

export const pool = new Pool({
connectionString: env.DATABASE_URL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-process-env */

import { z } from 'zod';

const schema = z.object({
Expand Down
12 changes: 0 additions & 12 deletions apps/dbagent/src/lib/env/db.ts

This file was deleted.

16 changes: 0 additions & 16 deletions apps/dbagent/src/lib/env/scheduler.ts

This file was deleted.

30 changes: 30 additions & 0 deletions apps/dbagent/src/lib/env/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable no-process-env */
import 'server-only';
import { z } from 'zod';
import { env as clientEnv } from './client';

const schema = z.object({
// The URL of the database that we use to store data
DATABASE_URL: z.string(),

// The OpenID client settings
AUTH_SECRET: z.string(),
AUTH_OPENID_ID: z.string(),
AUTH_OPENID_SECRET: z.string(),
AUTH_OPENID_ISSUER: z.string(),

// LLM API credentials
OPENAI_API_KEY: z.string(),
DEEPSEEK_API_KEY: z.string(),
ANTHROPIC_API_KEY: z.string(),

// How many schedules can run in parallel
MAX_PARALLEL_RUNS: z.number().default(20),

// How long to wait for a schedule to finish before assuming it's dead and running it again
TIMEOUT_FOR_RUNNING_SCHEDULE_SECS: z.number().default(15 * 60)
});

const serverEnv = schema.parse(process.env);

export const env = { ...clientEnv, ...serverEnv };
2 changes: 1 addition & 1 deletion apps/dbagent/src/lib/monitoring/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
setScheduleStatusRunning,
updateScheduleRunData
} from '~/lib/db/schedules';
import { env } from '../env/scheduler';
import { env } from '../env/server';
import { runSchedule } from './runner';

export function shouldRunSchedule(schedule: Schedule, now: Date): boolean {
Expand Down
2 changes: 1 addition & 1 deletion apps/dbagent/src/lib/notifications/slack-webhook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DbConnection } from '../db/connections';
import { getIntegration } from '../db/integrations';
import { Schedule } from '../db/schedules';
import { env } from '../env/general';
import { env } from '../env/client';

export type NotificationLevel = 'info' | 'warning' | 'alert';

Expand Down
1 change: 1 addition & 0 deletions apps/dbagent/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { auth as middleware } from '~/auth';
95 changes: 95 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading