refactor: ♻️ Don't use Bun global

This commit is contained in:
Jesse Wierzbinski 2025-03-30 23:06:34 +02:00
parent d55668d529
commit 25ea870f71
No known key found for this signature in database
15 changed files with 32 additions and 19 deletions

View file

@ -1,6 +1,7 @@
import { apiRoute, handleZodError } from "@/api";
import { Application, User } from "@versia/kit/db";
import { Users } from "@versia/kit/tables";
import { password as bunPassword } from "bun";
import { eq, or } from "drizzle-orm";
import type { Context } from "hono";
import { describeRoute } from "hono-openapi";
@ -143,7 +144,7 @@ export default apiRoute((app) =>
if (
!(
user &&
(await Bun.password.verify(
(await bunPassword.verify(
password,
user.data.password || "",
))

View file

@ -1,13 +1,13 @@
import { apiRoute, handleZodError } from "@/api";
import { User } from "@versia/kit/db";
import { Users } from "@versia/kit/tables";
import { password as bunPassword } from "bun";
import { eq } from "drizzle-orm";
import type { Context } from "hono";
import { describeRoute } from "hono-openapi";
import { validator } from "hono-openapi/zod";
import { z } from "zod";
import { config } from "~/config.ts";
const returnError = (
context: Context,
token: string,
@ -68,7 +68,7 @@ export default apiRoute((app) =>
}
await user.update({
password: await Bun.password.hash(password),
password: await bunPassword.hash(password),
passwordResetToken: null,
});

View file

@ -1,4 +1,5 @@
import { apiRoute, handleZodError } from "@/api";
import { file as bunFile } from "bun";
import { describeRoute } from "hono-openapi";
import { resolver, validator } from "hono-openapi/zod";
import { z } from "zod";
@ -57,7 +58,7 @@ export default apiRoute((app) =>
.map(Number); // [0, 100]
// Serve file from filesystem
const file = Bun.file(`./uploads/${hash}/${name}`);
const file = bunFile(`./uploads/${hash}/${name}`);
const buffer = await file.arrayBuffer();