Skip to content

Commit

Permalink
Refactor: Remove example environment files and update Supabase client…
Browse files Browse the repository at this point in the history
… configuration to use centralized config
  • Loading branch information
Luisotee committed Jan 22, 2025
1 parent 1deaa50 commit 60e659a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 68 deletions.
39 changes: 0 additions & 39 deletions deploy/langtrace-stack/.env.example

This file was deleted.

4 changes: 0 additions & 4 deletions packages/jobs/.env.example

This file was deleted.

12 changes: 3 additions & 9 deletions packages/jobs/lib/supabase.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
// TODO: should be moved to @eda/supabase, but currently having error: SyntaxError: Cannot use import statement outside a module
import { config } from "@eda/config";
import { createClient } from "@supabase/supabase-js";
// Generate the Typescript types using the Supabase CLI: https://supabase.com/docs/guides/api/rest/generating-types
// import type { Database } from "database.types";

// Create a single Supabase client for interacting with your database
// 'Database' supplies the type definitions to supabase-js
// export const supabase = createClient<Database>(
export const supabase = createClient(
// These details can be found in your Supabase project settings under `API`
process.env.SUPABASE_PROJECT_URL as string, // e.g. https://abc123.supabase.co - replace 'abc123' with your project ID
process.env.SUPABASE_SERVICE_ROLE_KEY as string, // Your service role secret key
config.databases.supabase.url,
config.api_keys.supabase.service_key,
);
13 changes: 13 additions & 0 deletions packages/jobs/schemas/monitor-api-calls.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { z } from "zod";

export const apiCallSchema = z.object({
endpoint: z.string(),
method: z.string(),
statusCode: z.number(),
duration: z.number(),
timestamp: z.string(),
sessionId: z.string(),
error: z.string().optional(),
});

export type ApiCall = z.infer<typeof apiCallSchema>;
6 changes: 2 additions & 4 deletions packages/jobs/trigger.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { config as edaConfig } from "@eda/config";
import type { TriggerConfig } from "@trigger.dev/sdk/v3";
import { config as dotenvConfig } from "dotenv";

dotenvConfig();

export const config: TriggerConfig = {
project: process.env.TRIGGER_PROJECT_ID ?? "",
project: edaConfig.services.trigger.project_id,
logLevel: "log",
maxDuration: 360,
retries: {
Expand Down
14 changes: 2 additions & 12 deletions packages/jobs/trigger/monitor-api-call.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import { task } from "@trigger.dev/sdk/v3";
import { z } from "zod";
import { logger } from "../../logger/src";

const apiCallSchema = z.object({
endpoint: z.string(),
method: z.string(),
statusCode: z.number(),
duration: z.number(),
timestamp: z.string(),
sessionId: z.string(),
error: z.string().optional(),
});
import type { ApiCall } from "../schemas/monitor-api-calls.schema";

export const monitorApiCallTask = task({
id: "monitor-api-call",
run: async (payload: z.infer<typeof apiCallSchema>, { ctx }) => {
run: async (payload: ApiCall, { ctx }) => {
logger.info("API Call monitored", {
endpoint: payload.endpoint,
statusCode: payload.statusCode,
Expand Down

0 comments on commit 60e659a

Please sign in to comment.