diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-07-08 16:44:14 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-07-08 16:44:14 +0200 |
commit | cae178eefdd024414a3ba90b43e9d95fbc85ef3c (patch) | |
tree | 9e14a68cfceccd24b989d3a5a0282b7033403091 /src/util | |
parent | 1.3.25 (diff) | |
download | server-cae178eefdd024414a3ba90b43e9d95fbc85ef3c.tar.xz |
:see_no_evil: :lock: hide db password in log
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/Database.ts | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/util/Database.ts b/src/util/Database.ts index 0732cb4e..ed596907 100644 --- a/src/util/Database.ts +++ b/src/util/Database.ts @@ -3,9 +3,10 @@ import mongoose, { Collection, Connection, LeanDocument } from "mongoose"; import { ChangeStream, ChangeEvent, Long } from "mongodb"; import EventEmitter from "events"; const uri = process.env.MONGO_URL || "mongodb://localhost:27017/fosscord?readPreference=secondaryPreferred"; +import { URL } from "url"; // TODO: auto throw error if findOne doesn't find anything -console.log(`[DB] connect: ${uri}`); +const url = new URL(uri.replace("mongodb://", "http://")); const connection = mongoose.createConnection(uri, { autoIndex: true, @@ -13,6 +14,7 @@ const connection = mongoose.createConnection(uri, { useUnifiedTopology: true, useFindAndModify: false, }); +console.log(`[DB] connect: mongodb://${url.username}@${url.host}${url.pathname}${url.search}`); export default <Connection>connection; |