Added lib stuff

This commit is contained in:
Fergal Moran
2024-01-19 11:51:29 +00:00
parent e9db82e479
commit eea4e7d058
4 changed files with 51 additions and 1 deletions

18
kirimase.config.json Normal file
View 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
View 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");
};

View File

@@ -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;
};

View File

@@ -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' })