mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
fix db conn for nextauth
This commit is contained in:
committed by
Thomas Ruoff
parent
893896cf31
commit
73bb989ca7
@@ -5,7 +5,9 @@ import { BOOKING_STATUS } from './enums'
|
|||||||
|
|
||||||
let connectedPromise: Promise<mongoose.Mongoose>
|
let connectedPromise: Promise<mongoose.Mongoose>
|
||||||
|
|
||||||
const MONGODB_OPTIONS = {
|
export const MONGO_URI = process.env.MONGO_URI;
|
||||||
|
|
||||||
|
export const MONGODB_OPTIONS = {
|
||||||
useCreateIndex: true,
|
useCreateIndex: true,
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
|
|||||||
@@ -3,17 +3,15 @@ import NextAuth from "next-auth"
|
|||||||
import EmailProvider from "next-auth/providers/email"
|
import EmailProvider from "next-auth/providers/email"
|
||||||
|
|
||||||
import { MongoDBAdapter } from "@next-auth/mongodb-adapter"
|
import { MongoDBAdapter } from "@next-auth/mongodb-adapter"
|
||||||
import { connect } from "../../../db"
|
import { MONGO_URI, MONGODB_OPTIONS } from "../../../db"
|
||||||
import { Mongoose } from 'mongoose';
|
import { MongoClient } from "mongodb";
|
||||||
import type { MongoClient } from "mongodb";
|
|
||||||
|
|
||||||
let mongooseConnection: Mongoose;
|
let mongooseConnection: Mongoose;
|
||||||
|
|
||||||
async function getMongoClient() {
|
async function getMongoClient() {
|
||||||
const mongoose: Mongoose = await connect();
|
const client = new MongoClient(MONGO_URI, MONGODB_OPTIONS);
|
||||||
|
await client.connect();
|
||||||
const mongoDatabase: unknown = mongoose.connection.db;
|
return client;
|
||||||
return mongoDatabase as MongoClient;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function auth(req: NextApiRequest, res: NextApiResponse) {
|
export default async function auth(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
|||||||
Reference in New Issue
Block a user