mongoose graphql shacdn next setup completed
This commit is contained in:
16
lib/auth.ts
Normal file
16
lib/auth.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { MongoDBAdapter } from '@auth/mongodb-adapter';
|
||||
import type { NextAuthOptions } from 'next-auth';
|
||||
import GitHubProvider from 'next-auth/providers/github';
|
||||
import clientPromise from './mongodb';
|
||||
|
||||
export const authOptions: NextAuthOptions = {
|
||||
adapter: MongoDBAdapter(clientPromise),
|
||||
providers: [
|
||||
GitHubProvider({
|
||||
clientId: process.env.GITHUB_ID!,
|
||||
clientSecret: process.env.GITHUB_SECRET!,
|
||||
}),
|
||||
],
|
||||
session: { strategy: 'jwt' },
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
};
|
||||
7
lib/mongodb.ts
Normal file
7
lib/mongodb.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// lib/mongodb.ts
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
export const connectDB = async () => {
|
||||
if (mongoose.connection.readyState >= 1) return;
|
||||
await mongoose.connect(process.env.MONGO_URI!);
|
||||
};
|
||||
6
lib/utils.ts
Normal file
6
lib/utils.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
Reference in New Issue
Block a user