2023-10-02 16:08:12 -04:00
|
|
|
import mongoose from "mongoose";
|
2023-12-20 17:23:31 -05:00
|
|
|
import { Biffno } from "@models/challenges/biffno";
|
|
|
|
import { Ficmas } from "@models/challenges/ficmas";
|
|
|
|
import { Challenge } from "@models/challenges/gen";
|
2023-10-11 16:51:03 -04:00
|
|
|
import { log } from "./logger";
|
2023-10-02 16:08:12 -04:00
|
|
|
|
|
|
|
export default async function () {
|
|
|
|
let beep = useRuntimeConfig();
|
|
|
|
Challenge;
|
|
|
|
Biffno;
|
|
|
|
Ficmas;
|
2023-10-11 16:51:03 -04:00
|
|
|
log.debug(mongoose.connection.modelNames());
|
2023-12-06 21:25:47 -05:00
|
|
|
// mongoose.set("debug", true);
|
|
|
|
mongoose.set("overwriteModels", true);
|
2023-12-29 12:45:15 -05:00
|
|
|
// console.log(process.env);
|
2023-10-02 16:08:12 -04:00
|
|
|
try {
|
2023-12-28 18:05:58 -05:00
|
|
|
await mongoose.connect(beep.database.uri, {
|
|
|
|
auth: {
|
|
|
|
username: beep.database.user,
|
|
|
|
password: beep.database.password,
|
|
|
|
},
|
|
|
|
authSource: "admin",
|
|
|
|
});
|
2023-10-02 16:08:12 -04:00
|
|
|
// if (!!!mongoose.connections.length)
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
2023-12-20 17:23:31 -05:00
|
|
|
throw createError({
|
|
|
|
statusCode: 500,
|
|
|
|
message: "Could not connect to the database.",
|
|
|
|
});
|
2023-10-02 16:08:12 -04:00
|
|
|
}
|
|
|
|
}
|