diff --git a/.prettierrc b/.prettierrc index 5c7b5d3..0272fba 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,7 @@ { "printWidth": 140, - "singleQuote": true, + "singleQuote": false, "semi": true, - "useTabs": true + "useTabs": true, + "tabWidth": 4 } diff --git a/package.json b/package.json index 6600fd0..148d347 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,18 @@ { - "name": "huskapi", - "version": "0.0.0", - "private": true, - "scripts": { - "deploy": "wrangler deploy", - "dev": "wrangler dev", - "start": "wrangler dev", - "test": "vitest", - "cf-typegen": "wrangler types" - }, - "devDependencies": { - "@cloudflare/vitest-pool-workers": "^0.5.2", - "@cloudflare/workers-types": "^4.20241112.0", - "typescript": "^5.5.2", - "vitest": "2.0.5", - "wrangler": "^3.60.3" - } -} \ No newline at end of file + "name": "huskapi", + "version": "0.0.0", + "private": true, + "scripts": { + "deploy": "wrangler deploy", + "dev": "wrangler dev", + "start": "wrangler dev", + "test": "vitest", + "cf-typegen": "wrangler types" + }, + "devDependencies": { + "@cloudflare/vitest-pool-workers": "^0.5.2", + "@cloudflare/workers-types": "^4.20241112.0", + "typescript": "^5.5.2", + "wrangler": "^3.60.3" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0eb4f1..3f140e9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,9 +17,6 @@ importers: typescript: specifier: ^5.5.2 version: 5.6.3 - vitest: - specifier: 2.0.5 - version: 2.0.5(@types/node@22.9.0) wrangler: specifier: ^3.60.3 version: 3.87.0(@cloudflare/workers-types@4.20241112.0) diff --git a/src/index.ts b/src/index.ts index 9efd7ce..5529398 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,18 +1,5 @@ -/** - * Welcome to Cloudflare Workers! This is your first worker. - * - * - Run `npm run dev` in your terminal to start a development server - * - Open a browser tab at http://localhost:8787/ to see your worker in action - * - Run `npm run deploy` to publish your worker - * - * Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the - * `Env` object can be regenerated with `npm run cf-typegen`. - * - * Learn more at https://developers.cloudflare.com/workers/ - */ - export default { async fetch(request, env, ctx): Promise { - return new Response('Hello World!'); + return new Response("Hello World!"); }, } satisfies ExportedHandler; diff --git a/test/index.spec.ts b/test/index.spec.ts deleted file mode 100644 index fbee335..0000000 --- a/test/index.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -// test/index.spec.ts -import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test'; -import { describe, it, expect } from 'vitest'; -import worker from '../src/index'; - -// For now, you'll need to do something like this to get a correctly-typed -// `Request` to pass to `worker.fetch()`. -const IncomingRequest = Request; - -describe('Hello World worker', () => { - it('responds with Hello World! (unit style)', async () => { - const request = new IncomingRequest('http://example.com'); - // Create an empty context to pass to `worker.fetch()`. - const ctx = createExecutionContext(); - const response = await worker.fetch(request, env, ctx); - // Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions - await waitOnExecutionContext(ctx); - expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); - }); - - it('responds with Hello World! (integration style)', async () => { - const response = await SELF.fetch('https://example.com'); - expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); - }); -}); diff --git a/test/tsconfig.json b/test/tsconfig.json deleted file mode 100644 index bc019a7..0000000 --- a/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "types": ["@cloudflare/workers-types/experimental", "@cloudflare/vitest-pool-workers"] - }, - "include": ["./**/*.ts", "../src/env.d.ts"], - "exclude": [] -} diff --git a/tsconfig.json b/tsconfig.json index 33bdb79..25f9248 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,9 +14,7 @@ /* Specify how TypeScript looks up a file from a given module specifier. */ "moduleResolution": "Bundler", /* Specify type package names to be included without being referenced in a source file. */ - "types": [ - "@cloudflare/workers-types/2023-07-01" - ], + "types": ["@cloudflare/workers-types/2023-07-01"], /* Enable importing .json files */ "resolveJsonModule": true, diff --git a/vitest.config.mts b/vitest.config.mts deleted file mode 100644 index 503a717..0000000 --- a/vitest.config.mts +++ /dev/null @@ -1,11 +0,0 @@ -import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config'; - -export default defineWorkersConfig({ - test: { - poolOptions: { - workers: { - wrangler: { configPath: './wrangler.toml' }, - }, - }, - }, -}); diff --git a/wrangler.toml b/wrangler.toml index c8c9054..f6499c6 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -27,8 +27,8 @@ enabled = true # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai -# [ai] -# binding = "AI" +[ai] +binding = "AI" # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function. # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets