fix: typecheck

This commit is contained in:
bekacru
2024-05-21 03:09:22 +03:00
parent 7fea813bc6
commit ecc6720cd4
6 changed files with 9 additions and 11 deletions

View File

@@ -23,7 +23,7 @@
"typescript": "5.5.0-dev.20240520"
},
"simple-git-hooks": {
"pre-commit": "pnpm format && pnpm lint:fix"
"pre-commit": "pnpm typecheck && pnpm format && pnpm lint:fix"
},
"devDependencies": {
"simple-git-hooks": "^2.11.1"

View File

@@ -1,10 +1,10 @@
import { MissingSecret } from "@better-auth/shared/error";
export const DEFAULT_SECRET = "better-auth-secret-key-123456789";
export const getSecret = (secret?: string) => {
secret = secret || process.env.BETTER_AUTH_SECRET || process.env.AUTH_SECRET;
const defaultSecret = "better-auth-secret-key-123456789";
if (process.env.NODE_ENV === "production" && !secret) {
throw new MissingSecret();
}
return secret || defaultSecret;
return secret || DEFAULT_SECRET;
};

View File

@@ -54,10 +54,6 @@ describe("to context", async () => {
const options: BetterAuthOptions = {
providers: [],
adapter: memoryAdapter({}),
pages: {
signIn: "/",
signUp: "/",
},
user: {
fields: {
email: { type: "string", required: true },

View File

@@ -7,6 +7,7 @@ import type { BetterAuthOptions } from "../src/options";
import { credential } from "../src/providers";
import { github } from "../src/providers/github";
import { getH3Server } from "./utils/server";
import { DEFAULT_SECRET } from "../src/utils/secret";
describe("signin handler", async (it) => {
const db = {
@@ -14,7 +15,7 @@ describe("signin handler", async (it) => {
{
id: "1234",
email: "test@email.com",
password: await hashPassword("test"),
password: await hashPassword("test", DEFAULT_SECRET),
firstName: "Test",
lastName: "User",
},

View File

@@ -6,6 +6,7 @@ import { hashPassword } from "../src/crypto/password";
import { credential } from "../src/providers";
import { github } from "../src/providers/github";
import { getH3Server } from "./utils/server";
import { DEFAULT_SECRET } from "../src/utils/secret";
describe("signin handler", async (it) => {
const db = {
@@ -13,7 +14,7 @@ describe("signin handler", async (it) => {
{
id: "1234",
email: "test@email.com",
password: await hashPassword("test"),
password: await hashPassword("test", DEFAULT_SECRET),
firstName: "Test",
lastName: "User",
},

View File

@@ -130,10 +130,10 @@ describe("Signup", async () => {
});
it("should verify email", async () => {
expect(db.user[0].emailVerified).toBe(false);
expect(db.user[0]?.emailVerified).toBe(false);
const response = await app.request(verifyEmailUrl);
const redirectedLocation = response.headers.get("Location");
expect(db.user[0].emailVerified).toBe(true);
expect(db.user[0]?.emailVerified).toBe(true);
expect(response.status).toBe(302);
expect(redirectedLocation).toBe("http://localhost:4002");
});