first commit

This commit is contained in:
luoyangwei
2026-06-06 00:49:07 +08:00
commit 2b860d201e
134 changed files with 22773 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
+56
View File
@@ -0,0 +1,56 @@
import NextAuth from "next-auth";
import Credentials from "next-auth/providers/credentials";
export const {
handlers: { GET, POST },
auth,
signIn,
signOut,
} = NextAuth({
providers: [
Credentials({
name: "Credentials",
credentials: {
email: { label: "Email", type: "email" },
password: { label: "Password", type: "password" },
},
async authorize(credentials) {
const adminEmail = process.env.ADMIN_EMAIL;
const adminPassword = process.env.ADMIN_PASSWORD;
if (
credentials?.email === adminEmail &&
credentials?.password === adminPassword
) {
return {
id: "admin",
name: "Admin",
email: adminEmail,
};
}
return null;
},
}),
],
pages: {
signIn: "/admin/login",
},
session: {
strategy: "jwt",
},
callbacks: {
async jwt({ token, user }) {
if (user) {
token.id = user.id;
}
return token;
},
async session({ session, token }) {
if (token?.id) {
session.user.id = token.id as string;
}
return session;
},
},
});
+1
View File
@@ -0,0 +1 @@
+1
View File
@@ -0,0 +1 @@
+1
View File
@@ -0,0 +1 @@
+21
View File
@@ -0,0 +1,21 @@
import { createClient } from "@supabase/supabase-js";
export function createSupabaseServiceRoleClient() {
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const serviceRoleKey = process.env.SUPABASE_SERVICE_ROLE_KEY;
if (!supabaseUrl) {
throw new Error("NEXT_PUBLIC_SUPABASE_URL is not configured.");
}
if (!serviceRoleKey) {
throw new Error("SUPABASE_SERVICE_ROLE_KEY is not configured.");
}
return createClient(supabaseUrl, serviceRoleKey, {
auth: {
persistSession: false,
autoRefreshToken: false,
},
});
}
+6
View 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));
}