chore: cleanup

This commit is contained in:
Bereket Engida
2025-04-13 20:01:18 +03:00
parent 886d532ec3
commit eb642c72ca
7 changed files with 18 additions and 16 deletions

View File

@@ -19,7 +19,7 @@
"prisma:normal:push": "prisma db push --schema src/adapters/prisma-adapter/test/normal-tests/schema.prisma",
"prisma:number-id:push": "prisma db push --schema src/adapters/prisma-adapter/test/number-id-tests/schema.prisma",
"bump": "bumpp",
"typecheck": "tsc --noEmit --project tsconfig.declarations.json"
"typecheck": "tsc --noEmit"
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",

View File

@@ -23,11 +23,7 @@ describe("adapter test", async () => {
await clearDb();
});
const adapter = mongodbAdapter(db, {
debugLogs: {
isRunningAdapterTests: true,
},
});
const adapter = mongodbAdapter(db);
await runAdapterTest({
getAdapter: async (customOptions = {}) => {
return adapter({

View File

@@ -16,11 +16,8 @@ import { BetterAuthError } from "./error";
export type WithJsDoc<T, D> = Expand<T & D>;
export const betterAuth = <
O extends BetterAuthOptions &
Record<Exclude<keyof O, keyof BetterAuthOptions>, never>,
>(
options: O,
export const betterAuth = <O extends BetterAuthOptions>(
options: O & Record<never, never>,
) => {
const authContext = init(options as O);
const { api } = getEndpoints(authContext, options as O);

View File

@@ -108,9 +108,6 @@ describe("multi-session", async () => {
});
await client.multiSession.revoke(
{
fetchOptions: {
headers,
},
sessionToken: token,
},
{
@@ -119,6 +116,7 @@ describe("multi-session", async () => {
`better-auth.session_token=`,
);
},
headers,
},
);
const res = await client.multiSession.listDeviceSessions({

View File

@@ -235,7 +235,7 @@ export const username = (options?: UsernameOptions) => {
},
handler: createAuthMiddleware(async (ctx) => {
const username = ctx.body.username;
if (username) {
if (username !== undefined && typeof username === "string") {
const minUsernameLength = options?.minUsernameLength || 3;
const maxUsernameLength = options?.maxUsernameLength || 30;
if (username.length < minUsernameLength) {

View File

@@ -101,4 +101,14 @@ describe("username", async (it) => {
expect(res.error?.status).toBe(422);
expect(res.error?.code).toBe("USERNAME_IS_TOO_SHORT");
});
it("should fail on empty username", async () => {
const res = await client.signUp.email({
email: "email-4@email.com",
username: "",
password: "new_password",
name: "new-name",
});
expect(res.error?.status).toBe(422);
});
});

View File

@@ -350,7 +350,8 @@ describe("Social Providers", async (c) => {
},
});
const authUrl = signInRes.data.url;
const authUrl = signInRes.data?.url;
if (!authUrl) throw new Error("No auth url found");
const mockEndpoint = authUrl.replace(
"https://accounts.google.com/o/oauth2/auth",
"http://localhost:8080/authorize",