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-10-02 16:08:12 -04:00
|
|
|
try {
|
|
|
|
await mongoose.connect(beep.database.uri);
|
|
|
|
// 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
|
|
|
}
|
|
|
|
}
|