Skip to content

Commit

Permalink
chore(deps): bump protobufjs from 6.11.2 to 6.11.3 (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Jul 13, 2022
1 parent 2b52c0e commit ca62bae
Show file tree
Hide file tree
Showing 2 changed files with 1,403 additions and 1,270 deletions.
10 changes: 7 additions & 3 deletions src/lib/mongodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ declare global {
var _mongoClientPromise: Promise<typeof MongoClient>
}

const globalWithMongo = global as typeof globalThis & {
_mongoClientPromise: Promise<typeof MongoClient>
}

const host = process.env.MONGO_HOST || ''
const user = process.env.MONGO_USER || ''
const password = process.env.MONGO_PASSWORD || ''
Expand All @@ -27,11 +31,11 @@ let clientPromise: Promise<typeof MongoClient>
if (process.env.NODE_ENV === 'development') {
// In development mode, use a global variable so that the value
// is preserved across module reloads caused by HMR (Hot Module Replacement).
if (!global._mongoClientPromise) {
if (!globalWithMongo._mongoClientPromise) {
client = new MongoClient(connectionString)
global._mongoClientPromise = client.connect()
globalWithMongo._mongoClientPromise = client.connect()
}
clientPromise = global._mongoClientPromise
clientPromise = globalWithMongo._mongoClientPromise
} else {
// In production mode, it's best to not use a global variable.
client = new MongoClient(connectionString)
Expand Down
Loading

0 comments on commit ca62bae

Please sign in to comment.