mirror of
https://github.com/YuzuZensai/Minikura.git
synced 2026-03-30 20:27:39 +00:00
✨ feat: initial prototype
This commit is contained in:
24
apps/web/lib/api-helpers.ts
Normal file
24
apps/web/lib/api-helpers.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { api } from "@/lib/api";
|
||||
|
||||
type ReverseProxyApi = {
|
||||
get: () => Promise<{ data?: unknown }>;
|
||||
(params: { id: string }): {
|
||||
delete: () => Promise<{ data?: unknown; error?: unknown }>;
|
||||
"connection-info": { get: () => Promise<{ data?: unknown }> };
|
||||
};
|
||||
};
|
||||
|
||||
type UserSuspensionApi = {
|
||||
suspension: {
|
||||
patch: (body: { isSuspended: boolean; suspendedUntil: string | null }) => Promise<{ error?: unknown }>;
|
||||
};
|
||||
};
|
||||
|
||||
export const getReverseProxyApi = (): ReverseProxyApi => {
|
||||
const apiRoot = api.api as unknown as { "reverse-proxy": ReverseProxyApi };
|
||||
return apiRoot["reverse-proxy"];
|
||||
};
|
||||
|
||||
export const getUserApi = (id: string): UserSuspensionApi => {
|
||||
return api.api.users({ id }) as unknown as UserSuspensionApi;
|
||||
};
|
||||
12
apps/web/lib/api.ts
Normal file
12
apps/web/lib/api.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { treaty } from "@elysiajs/eden";
|
||||
import type { App } from "@minikura/backend";
|
||||
|
||||
const baseUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3000";
|
||||
|
||||
export const api = treaty<App>(baseUrl, {
|
||||
fetch: {
|
||||
credentials: "include",
|
||||
},
|
||||
});
|
||||
|
||||
export type Api = typeof api;
|
||||
10
apps/web/lib/auth-client.ts
Normal file
10
apps/web/lib/auth-client.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createAuthClient } from "better-auth/react";
|
||||
import { adminClient } from "better-auth/client/plugins";
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
baseURL: process.env.NEXT_PUBLIC_API_URL || "http://localhost:3000",
|
||||
basePath: "/auth",
|
||||
plugins: [adminClient()],
|
||||
});
|
||||
|
||||
export const { useSession, signIn, signOut, signUp } = authClient;
|
||||
6
apps/web/lib/utils.ts
Normal file
6
apps/web/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