30 lines
686 B
TypeScript
30 lines
686 B
TypeScript
import mongoose from "mongoose";
|
|
import env from "../enviroment/env";
|
|
import fs from "fs";
|
|
|
|
const DBUrl = env.mongoURL as string;
|
|
|
|
console.log("db url", DBUrl);
|
|
|
|
if (env.useDocumentDB === "true") {
|
|
console.log("Using DocumentDB");
|
|
|
|
if (env.documentDBBundle === "true") {
|
|
const fileBuffer = fs.readFileSync("./rds-combined-ca-bundle.pem");
|
|
const mongooseCertificateConnect = mongoose as any;
|
|
|
|
mongooseCertificateConnect.connect(DBUrl, {
|
|
useCreateIndex: true,
|
|
useUnifiedTopology: true,
|
|
sslValidate: true,
|
|
sslCA: fileBuffer,
|
|
});
|
|
} else {
|
|
mongoose.connect(DBUrl, {});
|
|
}
|
|
} else {
|
|
mongoose.connect(DBUrl, {});
|
|
}
|
|
|
|
export default mongoose;
|