File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ import { MongoClient } from "./dependencies.ts";
22import getProviderUser from "./utils/get-user.ts" ;
33import DfContentMap from "./types/maps_interface.ts" ;
44
5- // Initialize MongoClient
6- const client = new MongoClient ( ) ;
5+ // Initialize MongoClient with npm driver
76const MONGO_URI = Deno . env . get ( "MONGO_URI" ) ;
7+ const client = MONGO_URI ? new MongoClient ( MONGO_URI ) : null ;
88
99console . log ( "--- DB INIT DEBUG ---" ) ;
1010console . log ( "CWD:" , Deno . cwd ( ) ) ;
@@ -18,10 +18,10 @@ let userAuthCollection: any;
1818let contentMapsCollection : any ;
1919
2020try {
21- if ( MONGO_URI ) {
21+ if ( MONGO_URI && client ) {
2222 console . log ( "Attempting to connect to MongoDB..." ) ;
23- await client . connect ( MONGO_URI ) ;
24- db = client . database ( "df_test" ) ;
23+ await client . connect ( ) ;
24+ db = client . db ( "df_test" ) ;
2525 userAuthCollection = db . collection ( "user_auth" ) ;
2626 contentMapsCollection = db . collection ( "content_maps" ) ;
2727 console . log ( "✅ Connected to MongoDB successfully" ) ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import { exec } from "https://deno.land/x/exec@0.0.5/mod.ts";
1111import * as Sentry from 'https://deno.land/x/sentry/index.mjs' ;
1212import { oakCors } from "https://deno.land/x/cors@v1.2.2/mod.ts" ;
1313import { load } from "https://deno.land/std@0.224.0/dotenv/mod.ts" ;
14- import { MongoClient , ObjectId } from "https://deno.land/x/mongo@v0.33.0/mod.ts " ;
14+ import { MongoClient , ObjectId } from "npm:mongodb@6.1.0 " ;
1515
1616try {
1717 await load ( { export : true } ) ; // Try default .env in CWD
You can’t perform that action at this time.
0 commit comments