Skip to content
Merged
Changes from all commits
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
6 changes: 3 additions & 3 deletions internal/worker/src/new-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export default function handleNewAPI(
env: Env,
ctx: ExecutionContext
) {
let databasePromise: ReturnType<typeof connectToDatabase> | undefined;

let apiBaseURL = new URL("https://blink.coder.com");
if (env.NODE_ENV === "development") {
apiBaseURL = new URL("http://localhost:3000");
Expand Down Expand Up @@ -122,9 +124,7 @@ export default function handleNewAPI(
return cli.fetch(request);
},
},
database: async () => {
return connectToDatabase(env);
},
database: () => (databasePromise ??= connectToDatabase(env)),
async deployAgent(deployment) {
const agentDeployment = env.AGENT_DEPLOYMENT.get(
env.AGENT_DEPLOYMENT.idFromName(deployment.id)
Expand Down
Loading