mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-09 15:11:29 -07:00
Initial commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# {{ slug name }}
|
||||
|
||||
A Cloudflare Workers application with a minimal fetch handler
|
||||
|
||||
## Development
|
||||
|
||||
### Run in dev mode
|
||||
|
||||
```sh
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
### Run tests
|
||||
|
||||
```sh
|
||||
pnpm test
|
||||
```
|
||||
|
||||
### Deploy
|
||||
|
||||
```sh
|
||||
pnpm turbo deploy
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
// oxlint-disable @typescript-eslint/consistent-type-imports
|
||||
type LocalEnv = import('./src/context').Env
|
||||
type MainModule = typeof import('./src/{{ slug name }}.app')
|
||||
|
||||
// Add Env to Cloudflare namespace so that we can access it via
|
||||
// import { env } from 'cloudflare:workers'
|
||||
declare namespace Cloudflare {
|
||||
interface Env extends LocalEnv {}
|
||||
interface GlobalProps {
|
||||
mainModule: MainModule
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "{{ slug name }}",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build:wrangler": "run-wrangler-build",
|
||||
"check:lint": "run-oxlint",
|
||||
"check:types": "run-tsc",
|
||||
"check:workers-types": "run-wrangler-types --check",
|
||||
"deploy": "run-wrangler-deploy",
|
||||
"dev": "run-wrangler-dev",
|
||||
"fix:workers-types": "run-wrangler-types",
|
||||
"test": "run-vitest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/vitest-pool-workers": "0.9.12",
|
||||
"@repo/tools": "workspace:*",
|
||||
"@repo/typescript-config": "workspace:*",
|
||||
"@types/node": "22.15.27",
|
||||
"vitest": "3.2.4",
|
||||
"wrangler": "4.42.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export type Env = {
|
||||
// add bindings here
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { SELF } from 'cloudflare:test'
|
||||
import { expect, it } from 'vitest'
|
||||
|
||||
it('response with hello world', async () => {
|
||||
const res = await SELF.fetch('https://example.com')
|
||||
expect(res.status).toBe(200)
|
||||
expect(await res.text()).toMatchInlineSnapshot(`"hello, world!"`)
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { Env } from './context'
|
||||
|
||||
export default {
|
||||
fetch: (_request, _env, _ctx) => {
|
||||
return new Response('hello, world!')
|
||||
},
|
||||
} satisfies ExportedHandler<Env>
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "@repo/typescript-config/workers.json"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { cloudflareTest } from '@cloudflare/vitest-pool-workers'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
cloudflareTest({
|
||||
wrangler: { configPath: `${__dirname}/wrangler.jsonc` },
|
||||
miniflare: {
|
||||
bindings: {
|
||||
ENVIRONMENT: 'VITEST',
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
})
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "node_modules/wrangler/config-schema.json",
|
||||
"name": "{{ slug name }}",
|
||||
"main": "src/{{ slug name }}.app.ts",
|
||||
"compatibility_date": "2025-09-20",
|
||||
"compatibility_flags": ["nodejs_compat"],
|
||||
"routes": [],
|
||||
"upload_source_maps": true,
|
||||
"observability": {
|
||||
"logs": {
|
||||
"enabled": true,
|
||||
"head_sampling_rate": 1 // 100%
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user