mirror of
https://github.com/fergalmoran/kidarr-server.git
synced 2025-12-22 09:17:51 +00:00
Added lib stuff
This commit is contained in:
18
kirimase.config.json
Normal file
18
kirimase.config.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"hasSrc": true,
|
||||
"packages": [
|
||||
"drizzle",
|
||||
"trpc",
|
||||
"next-auth",
|
||||
"shadcn-ui"
|
||||
],
|
||||
"preferredPackageManager": "bun",
|
||||
"t3": true,
|
||||
"alias": "@",
|
||||
"rootPath": "src/",
|
||||
"orm": "drizzle",
|
||||
"auth": "next-auth",
|
||||
"componentLib": "shadcn-ui",
|
||||
"provider": "node-postgres",
|
||||
"driver": "pg"
|
||||
}
|
||||
23
src/lib/auth/utils.ts
Normal file
23
src/lib/auth/utils.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { getServerAuthSession } from "@/server/auth";
|
||||
|
||||
export type AuthSession = {
|
||||
session: {
|
||||
user: {
|
||||
id: string;
|
||||
name?: string;
|
||||
email?: string;
|
||||
username?: string;
|
||||
};
|
||||
} | null;
|
||||
};
|
||||
|
||||
export const getUserAuth = async () => {
|
||||
const session = await getServerAuthSession();
|
||||
return { session } as AuthSession;
|
||||
};
|
||||
|
||||
export const checkAuth = async () => {
|
||||
const { session } = await getUserAuth();
|
||||
if (!session) redirect("/api/auth/signin");
|
||||
};
|
||||
@@ -4,3 +4,11 @@ import { twMerge } from "tailwind-merge";
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
|
||||
export type Action = "create" | "update" | "delete";
|
||||
|
||||
export type OptimisticAction<T> = {
|
||||
action: Action;
|
||||
data: T;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { drizzle } from "drizzle-orm/postgres-js";
|
||||
import postgres from "postgres";
|
||||
import * as schema from "./schema";
|
||||
import * as extended from "~/server/db/schema/_root";
|
||||
import { env } from "@/env";
|
||||
|
||||
const client = postgres(env.DATABASE_URL);
|
||||
export const db = drizzle(client, { schema });
|
||||
export const db = drizzle(client, { schema: { ...schema, ...extended } });
|
||||
|
||||
// console.log('DRIZZLE', 'migrating');
|
||||
// migrate(db, { migrationsFolder: 'drizzle' })
|
||||
|
||||
Reference in New Issue
Block a user