diff --git a/bin/test.mjs b/bin/test.mjs index a6da5b4..397fb15 100755 --- a/bin/test.mjs +++ b/bin/test.mjs @@ -4,16 +4,21 @@ import fs from "fs"; import { cmd } from "../src/cmd.mjs"; import consumers from "stream/consumers"; import openapiTS from "openapi-typescript"; +import { Miniflare } from "miniflare"; if (fs.existsSync("wrangler.toml")) { await cmd("wrangler deploy --dry-run --outdir=dist"); - const app = await import(`${process.cwd()}/dist/index.js`); - const request = await app.default.fetch( - { url: "http://example.com/doc", method: "GET" }, + const miniflare = new Miniflare({ + modules: true, + scriptPath: "dist/index.js", + }); + const request = await fetch( + `${await miniflare.ready}doc`, { SENTRY_DSN: null, SENTRY_ENVIRONMENT: null }, null, ); const types = await openapiTS(await consumers.json(request.body)); + await miniflare.dispose(); fs.writeFileSync("test/api.d.ts", types); } await cmd("vitest --globals --no-file-parallelism", [ diff --git a/package.json b/package.json index 5f658bc..8bb263c 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "name": "two-stroke", "packageManager": "yarn@4.1.0", "type": "module", - "version": "1.0.8", + "version": "1.0.9", "devDependencies": { "@types/eslint": "^8.56.5", "@types/node": "^20.11.25", diff --git a/src/types.ts b/src/types.ts index 6d77db1..92f1db7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,7 +1,14 @@ import { Toucan } from "toucan-js"; import { ZodObject, ZodSchema, z } from "zod"; export type Env = { - [k: string]: string | Queue | KVNamespace | R2Bucket | D1Database | Fetcher | Hyperdrive; + [k: string]: + | string + | Queue + | KVNamespace + | R2Bucket + | D1Database + | Fetcher + | Hyperdrive; }; export type Route = | {