AI prompts
base on Templates for Cloudflare Workers # Templates for Cloudflare Workers
Cloudflare Workers let you deploy serverless code instantly across the globe for exceptional performance, reliability, and scale. This repository contains a collection of starter templates for building full-stack applications on Workers. **You are encouraged to use, modify, and extend this code!**
## Getting Started
There are two ways to start building with a template in this repository: the [Cloudflare dashboard](https://dash.cloudflare.com/) and [C3](https://developers.cloudflare.com/pages/get-started/c3/) (the `create-cloudflare` CLI).
### Starting from the Dashboard
After logging in or signing up through the [Cloudflare dashboard](https://dash.cloudflare.com/), open the [Workers templates page](https://dash.cloudflare.com/?to=/:account/workers-and-pages/templates) and select a template to get started with. From here, you can create a repository and deploy your first Worker without needing a local development environment.
### Starting via CLI
To get started locally, run one of the following commands:
```bash
npm create cloudflare@latest
# or
pnpm create cloudflare@latest
# or
yarn create cloudflare@latest
```
For more information on getting started with our CLI, check out the [getting started guide](https://developers.cloudflare.com/workers/get-started/guide/).
### Additional Resources
Questions about Workers? Join the [official Cloudflare Discord](https://workers.community/) or check out the [Workers docs](https://developers.cloudflare.com/workers/)!
## End-to-End Testing
This repository includes a comprehensive Playwright-based E2E test suite that validates all templates to ensure they work correctly. The test system supports both **local development mode** (spinning up dev servers) and **live mode** (testing against deployed templates).
### Running E2E Tests
#### Local Development Mode (Default)
By default, tests run against locally started development servers:
```bash
# Run all E2E tests
pnpm run test:e2e
# Run tests for specific templates
pnpm run test:e2e astro-blog-starter-template.spec.ts
pnpm run test:e2e saas-admin-template.spec.ts
# Run tests with UI mode for debugging
pnpm run test:e2e --ui
```
In local mode:
- Tests start development servers automatically for each template
- Uses one worker to prevent port conflicts
- Servers are properly cleaned up between different template tests
- Longer timeouts to account for build and startup time
#### Live Mode (Testing Deployed Templates)
To test against live deployed templates, set the `PLAYWRIGHT_USE_LIVE` environment variable:
```bash
# Run tests against live deployed templates
pnpm run test:e2e:live
# Run specific template tests in live mode
pnpm run test:e2e:live saas-admin-template.spec.ts
```
In live mode:
- Tests run against `https://{template-name}.templates.workers.dev`
- Enables parallel execution (up to 4 workers locally, 2 in CI)
- Faster execution since no local server startup required
- Shorter timeouts since templates are already running
### Test Architecture
The test system includes:
- **Automatic template discovery**: Finds all `*-template` directories and analyzes their framework
- **Smart server management**: Detects framework type (Astro, Next.js, Vite, etc.) and uses appropriate ports
- **Reliable cleanup**: Properly terminates process trees between test runs
- **Flexible URL resolution**: Automatically determines live URLs from `wrangler.json` configuration
### Writing Template Tests
Template tests should be named `{template-name}.spec.ts` and placed in the `playwright-tests/` directory:
```typescript
import { test, expect } from "./fixtures";
test.describe("My Template", () => {
test("should render correctly", async ({ page, templateUrl }) => {
await page.goto(templateUrl);
await expect(page.getByRole("heading", { name: "Welcome" })).toBeVisible();
});
});
```
The `templateUrl` fixture automatically provides the correct URL (local dev server or live deployment) based on the test mode.
#### Playwright Codegen
Playwright includes a test code generation utility that records your actions in a chromium browswer. To start the codegen utility run
```bash
pnpm playwright codgen
```
## Contributing
We welcome template contributions! If there's a Workers template you think would be valuable, please read our [contributing guide](./CONTRIBUTING.md) and open an issue or pull request.
", Assign "at most 3 tags" to the expected json: {"id":"13827","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"