mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor: ♻️ Don't use Bun global
This commit is contained in:
parent
d55668d529
commit
25ea870f71
15 changed files with 32 additions and 19 deletions
|
|
@ -34,6 +34,7 @@ import {
|
|||
Users,
|
||||
} from "@versia/kit/tables";
|
||||
import { randomUUIDv7 } from "bun";
|
||||
import { password as bunPassword } from "bun";
|
||||
import chalk from "chalk";
|
||||
import {
|
||||
type InferInsertModel,
|
||||
|
|
@ -890,7 +891,7 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
|||
password:
|
||||
data.skipPasswordHash || !data.password
|
||||
? data.password
|
||||
: await Bun.password.hash(data.password),
|
||||
: await bunPassword.hash(data.password),
|
||||
email: data.email,
|
||||
note: data.bio ?? "",
|
||||
avatarId: data.avatar?.id,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import type {
|
|||
import { Instance, Like, Note, Relationship, User } from "@versia/kit/db";
|
||||
import { Likes, Notes } from "@versia/kit/tables";
|
||||
import type { SocketAddress } from "bun";
|
||||
import { Glob } from "bun";
|
||||
import chalk from "chalk";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { matches } from "ip-matching";
|
||||
|
|
@ -31,7 +32,7 @@ import { ApiError } from "../errors/api-error.ts";
|
|||
* @returns {boolean} - True if defederated, false otherwise.
|
||||
*/
|
||||
function isDefederated(hostname: string): boolean {
|
||||
const pattern = new Bun.Glob(hostname);
|
||||
const pattern = new Glob(hostname);
|
||||
|
||||
return (
|
||||
config.federation.blocked.find(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
* @module MediaManager/Utils
|
||||
*/
|
||||
|
||||
import { SHA256 } from "bun";
|
||||
|
||||
/**
|
||||
* Generates a SHA-256 hash for a given file.
|
||||
* @param file - The file to hash.
|
||||
|
|
@ -10,6 +12,6 @@
|
|||
*/
|
||||
export const getMediaHash = async (file: File): Promise<string> => {
|
||||
const arrayBuffer = await file.arrayBuffer();
|
||||
const hash = new Bun.SHA256().update(arrayBuffer).digest("hex");
|
||||
const hash = new SHA256().update(arrayBuffer).digest("hex");
|
||||
return hash;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { readdir } from "node:fs/promises";
|
||||
import { type Logger, getLogger } from "@logtape/logtape";
|
||||
import { file, sleep } from "bun";
|
||||
import chalk from "chalk";
|
||||
import { parseJSON5, parseJSONC } from "confbox";
|
||||
import type { Hono } from "hono";
|
||||
|
|
@ -59,7 +60,7 @@ export class PluginLoader {
|
|||
manifestPath: string,
|
||||
manifestFile: string,
|
||||
): Promise<unknown> {
|
||||
const manifestText = await Bun.file(manifestPath).text();
|
||||
const manifestText = await file(manifestPath).text();
|
||||
|
||||
try {
|
||||
if (manifestFile.endsWith(".json")) {
|
||||
|
|
@ -238,7 +239,7 @@ export class PluginLoader {
|
|||
logger.fatal`Here is the error message, please fix the configuration file accordingly:`;
|
||||
logger.fatal`${(e as ValidationError).message}`;
|
||||
|
||||
await Bun.sleep(Number.POSITIVE_INFINITY);
|
||||
await sleep(Number.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
const time2 = performance.now();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue