next/server/middleware/00.dbconn.ts

19 lines
523 B
TypeScript
Raw Normal View History

import mongoose from "mongoose"
import {Ficmas} from "~/models/challenges/ficmas"
import {Challenge} from "~/models/challenges/gen"
import {Biffno} from "~/models/challenges/biffno"
export default eventHandler(async (event) => {
let beep = useRuntimeConfig()
console.log(beep)
Challenge;
Biffno;
Ficmas;
try {
console.log("connecting........")
await mongoose.connect(beep.database.uri)
} catch(e) {
console.error(e)
throw createError({statusCode: 500, message: "whoops."})
}
})