scruffy
scruffy
Explore posts from servers
CDCloudflare Developers
Created by scruffy on 11/18/2024 in #workers-help
Where's the best place to ask about / suggest features for wrangler?
In case it's here, my thought was: There doesn't seem to be any checks for missing environment variables/secrets on wrangler deploy, which feels like a missed opportunity... I might be missing something obvious, but presumably once built, the code could be scanned for environment variables/secrets and any instances could be checked against wrangler.toml and the production worker (if it exists), to ensure that no variables/secrets are missing. If there are any missing variables/secrets, the deployment could then fail and provide feedback. If this isn't the best place for this, where might be better?
4 replies
CDCloudflare Developers
Created by scruffy on 8/25/2024 in #workers-help
Intermittent errors with wrangler deploy
I have a monorepo with a number of workers and pages apps and am running into issues with deployments via wrangler deploy... For now, I'm using pnpm run -r deploy to run the deploy tasks in each workspace and am getting workers.api.error.unknown [code: 10013], although it's not always on the same app. When I run the deployments individually from each app, everything works fine. Currently there are only 3 workers and 2 pages apps, but I'm planning on having several more of each (and using GHA). Is it likely that I'm hitting a rate limit or is it more likely to be something else?
35 replies
HHono
Created by scruffy on 6/28/2024 in #help
Using Vitest with Hono JSX // Error: Expression expected
Hi there, I'm trying to add vitest to a hono project (I've not used vitest before) and am running into a problem... The following code works fine in the browser -- hitting root on localhost shows a page with an H1 of "Hello world". When I run vitest run, I get "Error: Expression expected". Can anybody tell me what I'm doing wrong? Fingers crossed and thanks for any help 🙂
// tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"checkJs": true,
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx",
"noEmit": true
}
}
// tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"checkJs": true,
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx",
"noEmit": true
}
}
// index.js
import { Hono } from 'hono'
import { home } from './lib/home'

const app = new Hono()

app.get('/', (c) => home(c))

export default app
// index.js
import { Hono } from 'hono'
import { home } from './lib/home'

const app = new Hono()

app.get('/', (c) => home(c))

export default app
// lib/home.js
import { Home } from '../views/Home'

const props = {
message: 'Hello world'
}

export const home = (c) => c.html(
<Home {...props} />
)
// lib/home.js
import { Home } from '../views/Home'

const props = {
message: 'Hello world'
}

export const home = (c) => c.html(
<Home {...props} />
)
// views/Home.jsx
const Layout = (props) => (
<html>
<body>
{props.children}
</body>
</html>
)

export const Home = (props) => (
<Layout {...props}>
<h1>{props.message}</h1>
</Layout>
)
// views/Home.jsx
const Layout = (props) => (
<html>
<body>
{props.children}
</body>
</html>
)

export const Home = (props) => (
<Layout {...props}>
<h1>{props.message}</h1>
</Layout>
)
// index.test.js
import { describe, expect, test } from 'vitest'
import index from './index'

describe('index worker', () => {
test('GET /', async () => {
const res = await index.request('/')
expect(res.status).toBe(200)
const body = (await res.text())
expect(body).toBe('Hello world')
})
})
// index.test.js
import { describe, expect, test } from 'vitest'
import index from './index'

describe('index worker', () => {
test('GET /', async () => {
const res = await index.request('/')
expect(res.status).toBe(200)
const body = (await res.text())
expect(body).toBe('Hello world')
})
})
3 replies
CDCloudflare Developers
Created by scruffy on 6/27/2023 in #general-help
"Virtual subdomain" Transform Rules
I'd like to use Transform Rules to catch any requests to any subdomain on a domain managed by Cloudflare and dynamically transform the URL and redirect to something like https://domain.tld/subdomain. Ideally, I'd like to do this without having to create DNS entries for each subdomain... is this possible? My hunch is that this might not be possible, but wanted to check I'm not missing something.
3 replies