mirror of
https://github.com/better-auth/better-auth.git
synced 2026-07-30 17:12:35 -05:00
chore: wip
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
import type { EndpointOptions } from "better-call";
|
||||
import { betterAuth } from "../src";
|
||||
import { ZodObject, ZodString } from "zod";
|
||||
|
||||
export const auth = betterAuth({});
|
||||
|
||||
type SchemaType = "string" | "number" | "boolean" | "object" | "array";
|
||||
|
||||
const components = {
|
||||
schemas: {
|
||||
ErrBadRequest: {
|
||||
type: "object",
|
||||
properties: {
|
||||
error: {
|
||||
type: "object",
|
||||
properties: {
|
||||
message: {
|
||||
type: "string",
|
||||
description: "A human readable explanation of what went wrong",
|
||||
},
|
||||
},
|
||||
required: ["message"],
|
||||
},
|
||||
},
|
||||
required: ["error"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const errors = {
|
||||
badRequest: "ErrBadRequest",
|
||||
};
|
||||
|
||||
interface Path {
|
||||
get?: {
|
||||
tags?: string[];
|
||||
operationId?: string;
|
||||
security?: {
|
||||
bearerAuth: string[];
|
||||
};
|
||||
parameters?: {
|
||||
schema?: {
|
||||
type: SchemaType;
|
||||
minLength: number;
|
||||
description?: string;
|
||||
example?: string;
|
||||
};
|
||||
required?: boolean;
|
||||
name: string;
|
||||
in: string;
|
||||
}[];
|
||||
responses?: {
|
||||
[key in 200 | 400 | 401 | 403 | 500]: {
|
||||
description?: string;
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type?: SchemaType;
|
||||
properties?: Record<string, any>;
|
||||
required?: string[];
|
||||
$ref?: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
const paths: Record<string, Path> = {};
|
||||
|
||||
Object.entries(auth.api).forEach(([key, value]) => {
|
||||
const options = value.options as EndpointOptions;
|
||||
if (options.method === "GET") {
|
||||
if (options.query instanceof ZodObject) {
|
||||
Object.entries(options.query.shape).forEach(([key, value]) => {
|
||||
if (value instanceof ZodString) {
|
||||
console.log(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -32,12 +32,15 @@ export type InferSessionAPI<API> = API extends {
|
||||
E extends Endpoint
|
||||
? E["path"] extends "/get-session"
|
||||
? {
|
||||
getSession: (context: {
|
||||
getSession: ((context: {
|
||||
headers: Headers;
|
||||
query?: {
|
||||
disableCookieCache?: boolean;
|
||||
};
|
||||
}) => Promise<PrettifyDeep<Awaited<ReturnType<E>>>>;
|
||||
}) => Promise<PrettifyDeep<Awaited<ReturnType<E>>>>) & {
|
||||
options: E["options"];
|
||||
path: E["path"];
|
||||
};
|
||||
}
|
||||
: never
|
||||
: never
|
||||
|
||||
Reference in New Issue
Block a user