🙈 🔒 hide db password in log
This commit is contained in:
parent
786d3d954a
commit
cae178eefd
@ -3,9 +3,10 @@ import mongoose, { Collection, Connection, LeanDocument } from "mongoose";
|
|||||||
import { ChangeStream, ChangeEvent, Long } from "mongodb";
|
import { ChangeStream, ChangeEvent, Long } from "mongodb";
|
||||||
import EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
const uri = process.env.MONGO_URL || "mongodb://localhost:27017/fosscord?readPreference=secondaryPreferred";
|
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
|
// 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, {
|
const connection = mongoose.createConnection(uri, {
|
||||||
autoIndex: true,
|
autoIndex: true,
|
||||||
@ -13,6 +14,7 @@ const connection = mongoose.createConnection(uri, {
|
|||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
useFindAndModify: false,
|
useFindAndModify: false,
|
||||||
});
|
});
|
||||||
|
console.log(`[DB] connect: mongodb://${url.username}@${url.host}${url.pathname}${url.search}`);
|
||||||
|
|
||||||
export default <Connection>connection;
|
export default <Connection>connection;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user