refactor: migrate monorepo from pnpm to Bun runtime and workspaces
- root: bun workspaces via package.json, packageManager bun@1.4.0, scripts use bun --filter - backend: Bun.serve, bun test (vitest removed), bun --watch dev script, tsconfig types bun - tests: migrate 6 test files from vitest to bun:test (mock.module) - validate: replace @hono/zod-validator with hono validator + zod safeParse (fixes TS2589) - lockfile: bunfig.toml saveTextLockfile, regenerated bun.lock (text) for turbo - docs: AGENTS.md, README.md, stack.md updated to Bun stack
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
import { beforeEach, describe, expect, it, mock, vi } from 'bun:test';
|
||||
import { Hono } from 'hono';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
vi.mock('@/lib/prisma', () => ({
|
||||
default: {
|
||||
$queryRaw: vi.fn(),
|
||||
},
|
||||
getPrismaClient: vi.fn(),
|
||||
const db = {
|
||||
$queryRaw: mock(),
|
||||
};
|
||||
|
||||
mock.module('@/lib/prisma', () => ({
|
||||
default: db,
|
||||
getPrismaClient: mock(() => db),
|
||||
UnitOfWork: class {},
|
||||
}));
|
||||
|
||||
vi.mock('@/modules/auth/auth', () => ({
|
||||
mock.module('@/modules/auth/auth', () => ({
|
||||
auth: {
|
||||
api: {
|
||||
getSession: vi.fn(),
|
||||
getSession: mock(),
|
||||
},
|
||||
},
|
||||
}));
|
||||
@@ -48,7 +50,7 @@ describe('session auth', () => {
|
||||
});
|
||||
|
||||
it('rejects protected requests without a session', async () => {
|
||||
vi.mocked(auth.api.getSession).mockResolvedValue(null);
|
||||
auth.api.getSession.mockResolvedValue(null);
|
||||
|
||||
const app = new Hono();
|
||||
app.use('*', sessionAuthMiddleware);
|
||||
@@ -65,7 +67,7 @@ describe('session auth', () => {
|
||||
user: { id: 'user-1', name: 'Ana' },
|
||||
session: { id: 'session-1' },
|
||||
};
|
||||
vi.mocked(auth.api.getSession).mockResolvedValue(session as never);
|
||||
auth.api.getSession.mockResolvedValue(session as never);
|
||||
|
||||
const app = new Hono();
|
||||
app.use('*', sessionAuthMiddleware);
|
||||
|
||||
Reference in New Issue
Block a user