mirror of
https://github.com/saltbo/zpan.git
synced 2026-08-28 15:51:29 +08:00
310e4950b3
Replace pnpm workspace monorepo (packages/server, packages/web, packages/shared) with a flat single-package layout following Hono's pages-stack pattern. Switch from pnpm to npm and from Workers+Assets to CF Pages Functions deployment model. - Move source: packages/server/src/ → server/, packages/web/src/ → src/, packages/shared/src/ → shared/ - Add functions/api/[[route]].ts as CF Pages Functions entry (replaces entry-cloudflare.ts) - Update 22 import paths: server uses relative, web uses @shared/@server aliases - Merge three package.json into one, switch to npm - Update wrangler.toml: remove main/assets (Pages auto-detects functions/ dir) - Add per-directory tsconfig.json for VS Code type resolution - Simplify Dockerfile for flat layout - Fix react-pdf CSS import path (dist/esm/ → dist/) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
953 B
TypeScript
28 lines
953 B
TypeScript
import { env } from 'cloudflare:workers'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { createApp } from '../app'
|
|
import { createAuth } from '../auth'
|
|
import { createCloudflarePlatform } from '../platform/cloudflare'
|
|
|
|
function buildApp() {
|
|
const platform = createCloudflarePlatform(env)
|
|
const auth = createAuth(platform.db, env.BETTER_AUTH_SECRET)
|
|
return createApp(platform, auth)
|
|
}
|
|
|
|
describe('[CF] System API', () => {
|
|
it('GET /api/system/options returns empty list without auth', async () => {
|
|
const app = buildApp()
|
|
const res = await app.request('/api/system/options')
|
|
expect(res.status).toBe(200)
|
|
const body = (await res.json()) as { items: unknown[]; total: number }
|
|
expect(Array.isArray(body.items)).toBe(true)
|
|
})
|
|
|
|
it('GET unknown option returns 404', async () => {
|
|
const app = buildApp()
|
|
const res = await app.request('/api/system/options/nonexistent_key')
|
|
expect(res.status).toBe(404)
|
|
})
|
|
})
|