bkyerv
bkyerv
Explore posts from servers
CDCloudflare Developers
Created by bkyerv on 10/30/2024 in #workers-help
Cloudflare Workflows Binding Error in Astro Project
No description
1 replies
CDCloudflare Developers
Created by bkyerv on 10/30/2024 in #workers-help
Integrating Cloudflare Workflows with Astro
I'm trying to integrate the newly announced Cloudflare Workflows with an existing Astro project (not using the starter template) and running into some TypeScript issues. Issue 1: Module Resolution Getting error on import:
import { WorkflowEntrypoint, WorkflowStep, WorkflowEvent } from "cloudflare:workers";
// Error: Cannot find module 'cloudflare:workers' or its corresponding type declarations.ts
import { WorkflowEntrypoint, WorkflowStep, WorkflowEvent } from "cloudflare:workers";
// Error: Cannot find module 'cloudflare:workers' or its corresponding type declarations.ts
Issue 2: Type Arguments Example from docs throwing TS error:
const apiResponse = await step.do("some other step", async () => {
let resp = await fetch("https://api.cloudflare.com/client/v4/ips");
return await resp.json<any>(); // Error: Expected 0 type arguments, but got 1.ts(2558)
});
const apiResponse = await step.do("some other step", async () => {
let resp = await fetch("https://api.cloudflare.com/client/v4/ips");
return await resp.json<any>(); // Error: Expected 0 type arguments, but got 1.ts(2558)
});
Current setup
{
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/cloudflare": "^11.2.0",
"@astrojs/node": "^8.3.4",
"@astrojs/tailwind": "^5.1.2",
"@cloudflare/workers-types": "^4.20241022.0",
"astro": "^4.16.7",
"tailwindcss": "^3.4.14",
"typescript": "^5.6.3"
}
}
{
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/cloudflare": "^11.2.0",
"@astrojs/node": "^8.3.4",
"@astrojs/tailwind": "^5.1.2",
"@cloudflare/workers-types": "^4.20241022.0",
"astro": "^4.16.7",
"tailwindcss": "^3.4.14",
"typescript": "^5.6.3"
}
}
Questions: What's the correct way to set up Workflows in an existing Astro project? What should the folder structure look like? Are there any specific configuration steps needed for TypeScript to recognize the cloudflare:workers module? How do we properly type the json<T>() response? Any help or guidance would be greatly appreciated! šŸ™
1 replies
CDCloudflare Developers
Created by bkyerv on 10/16/2024 in #pages-help
Need Help with Astro + Cloudflare + Turso DB Setup
Hey everyone, Iā€™m running into an issue with my Astro app. Locally, everything works fine, but in production on Cloudflare, Iā€™m getting a 401 Unauthorized error when trying to insert data into the database (db.insert(Waitlist_signups)). Iā€™m using Turso for the database as per the documentation and have added the necessary environment variables (both the DB token and URL) in Cloudflare, but still facing this issue. Has anyone encountered something similar or know what could be causing the 401 error? Thanks in advance for any help!
4 replies
CDCloudflare Developers
Created by bkyerv on 10/15/2024 in #pages-help
Issue with Remix App Deployment on Cloudflare Pages - 404 Error After Successful Deploy
Iā€™m having trouble deploying a simple Remix app. I created the app by running npm run remix@latest, pushed the local repo to GitHub, and connected it to Cloudflare Pages. I set up the deployment and picked the correct repo. The deployment is successful, but when I click the link, Iā€™m getting a 404 error instead of the page being rendered. I followed the Pages documentation and pointed to the correct build/client folder. Any ideas on what could be wrong?
5 replies
CDCloudflare Developers
Created by bkyerv on 9/30/2024 in #general-help
Locating Worker file in static assets (Astro) server from worker
I'm working on a project using Astro as a framework for a Cloudflare Worker, but I'm a bit lost in the project structure. I used the npm create cloudflare@latest command to set up the project, which gave me what looks like a standard Astro project. My main questions are: - Where should I place the Worker code? Or has it already been set up by the Cloudflare package? - In general, where can I find the Worker-specific parts of this project? If anyone has experience with this setup, I'd really appreciate some guidance on navigating the project structure and identifying where these Cloudflare Worker elements fit in. Thanks in advance for any help!
2 replies
CDCloudflare Developers
Created by bkyerv on 9/11/2024 in #general-help
Cloudflared setup: Empty config.yml file - Manual creation or automatic generation?
Hey everyone, I'm trying to set up cloudflared but I'm hitting a snag. I'm getting an error saying my config file at /Users/by/.cloudflared/config.yml is empty. I'm not sure if I need to create this file manually or if there's a command that should generate it automatically. Has anyone dealt with this before? Any tips on how to properly populate the config file? Thanks in advance!
5 replies
CDCloudflare Developers
Created by bkyerv on 11/17/2023 in #workers-help
Troubleshooting Hono with Cloudflare Durable Objects Implementation Error
I'm currently working on integrating Hono with Cloudflare Durable Objects following this (url: https://github.com/honojs/examples/tree/main/durable-objects/src) example: Hono Example. However, I've run into a snag and need some help troubleshooting. My implementation, which is essentially a replica of the original example, can be found here: My Hono Implementation (url: https://github.com/bkyerv/hono-cloudfalre-do/tree/main/src ). I'm encountering the following error:
Error:
service core:user:worker-lawyer: Uncaught TypeError: Class extends value undefined is not a constructor or null
at index.js:1677:44 in maskDurableObjectDefinition
at index.js:1686:16
āœ˜ [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
Error:
service core:user:worker-lawyer: Uncaught TypeError: Class extends value undefined is not a constructor or null
at index.js:1677:44 in maskDurableObjectDefinition
at index.js:1686:16
āœ˜ [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
7 replies
CDCloudflare Developers
Created by bkyerv on 11/3/2023 in #general-help
Issue with Setting Up Cloudflare Tunnel for Local Development
I'm attempting to establish a Cloudflare tunnel to grant access to applications and servers that are running locally during the development phase. However, I'm encountering an error while setting up the tunnel using cloudflared command used cloudflared tunnel --url http://localhost:3000 output I am seeing
INF Requesting new quick Tunnel on trycloudflare.com...
failed to parse quick Tunnel ID: invalid UUID length: 0
INF Requesting new quick Tunnel on trycloudflare.com...
failed to parse quick Tunnel ID: invalid UUID length: 0
2 replies
CDCloudflare Developers
Created by bkyerv on 11/3/2023 in #general-help
Issue with Updating Cloudflared using Homebrew
While attempting to update cloudflared as per the update instructions on https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/update-cloudflared/, I encountered an error during the upgrade process. Command used brew upgrade cloudflared Output:
brew upgrade cloudflared
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################### 100.0%
==> Upgrading 1 outdated package:
cloudflare/cloudflare/cloudflared 2023.3.1 -> 2023.8.2
==> Fetching cloudflare/cloudflare/cloudflared
==> Downloading https://packages.argotunnel.com/dl/cloudflared-2023.8.2-darwin-a
curl: (22) The requested URL returned error: 522 # # # #

Error: cloudflared: Failed to download resource "cloudflared"
Download failed: https://packages.argotunnel.com/dl/cloudflared-2023.8.2-darwin-amd64.tgz
brew upgrade cloudflared
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################### 100.0%
==> Upgrading 1 outdated package:
cloudflare/cloudflare/cloudflared 2023.3.1 -> 2023.8.2
==> Fetching cloudflare/cloudflare/cloudflared
==> Downloading https://packages.argotunnel.com/dl/cloudflared-2023.8.2-darwin-a
curl: (22) The requested URL returned error: 522 # # # #

Error: cloudflared: Failed to download resource "cloudflared"
Download failed: https://packages.argotunnel.com/dl/cloudflared-2023.8.2-darwin-amd64.tgz
2 replies
CDCloudflare Developers
Created by bkyerv on 9/6/2023 in #workers-help
Cloudflare Worker "exceeded CPU" Error on Auth Endpoint - Seeking Troubleshooting Insights
I've set up a Cloudflare Worker to handle an authentication endpoint. However, I'm encountering an error that states 'exceeded CPU'. I'm trying to understand the potential causes for surpassing the allocated CPU bandwidth. Any insights or troubleshooting suggestions would be greatly appreciated.
app.post('/signup', async (c) => {
const { email, password } = await c.req.json();
const auth = initializeAuth(c.env.TURSO_DB_URL, c.env.TURSO_AUTH_TOKEN);

try {
const userDetails = await auth
.createUser({
key: {
providerId: 'email',
providerUserId: email,

password,
},
attributes: {},
})
.catch(console.log);
console.log(userDetails);
return c.json({ status: 'ok' });
} catch (e) {
return c.json({ status: 'error', message: e });
}
});
app.post('/signup', async (c) => {
const { email, password } = await c.req.json();
const auth = initializeAuth(c.env.TURSO_DB_URL, c.env.TURSO_AUTH_TOKEN);

try {
const userDetails = await auth
.createUser({
key: {
providerId: 'email',
providerUserId: email,

password,
},
attributes: {},
})
.catch(console.log);
console.log(userDetails);
return c.json({ status: 'ok' });
} catch (e) {
return c.json({ status: 'error', message: e });
}
});
6 replies
DTDrizzle Team
Created by bkyerv on 8/27/2023 in #help
Strugling to use composite key in schema
How do I represent composite primary key in drizzle way (sqlite) below migration query? I red the docs but failed miserable in trying to implement it.
CREATE TABLE QuestionSetMapping (
SetID INTEGER,
QuestionID INTEGER,
PRIMARY KEY(SetID, QuestionID),
FOREIGN KEY(SetID) REFERENCES QuestionSets(SetID),
FOREIGN KEY(QuestionID) REFERENCES Questions(QuestionID)
);
CREATE TABLE QuestionSetMapping (
SetID INTEGER,
QuestionID INTEGER,
PRIMARY KEY(SetID, QuestionID),
FOREIGN KEY(SetID) REFERENCES QuestionSets(SetID),
FOREIGN KEY(QuestionID) REFERENCES Questions(QuestionID)
);
5 replies
DTDrizzle Team
Created by bkyerv on 8/4/2023 in #help
Discrepancies Between Raw SQL Queries and ORM Operations: Why Might They Behave Differently?
1 replies
CDCloudflare Developers
Created by bkyerv on 8/4/2023 in #general-help
accessing env vars outside of worker
Is it possible to access env vars that are defined in the wrangler.toml file outside of workers? In this particular case I need to pass connection url and auth token to drizzle config file. That file is located in the root of the project and has nothing to do with workers. I am hesitant to insert credential hardcoded as is in the config file
1 replies
CDCloudflare Developers
Created by bkyerv on 4/10/2023 in #pages-help
remix app deployed using pages
Has anyone come across a situation where an empty screen is rendered upon deployment? I have set env var node_version to 16.10
11 replies
CDCloudflare Developers
Created by bkyerv on 2/6/2023 in #pages-help
is it possible to pass runtime env variables to supabase project?
When deploying a vite based app that uses supabase to perform authentication of the users of the app is it possible to pass supabase env variables so that such env variables can be used in the runtime without being exposed on the client? Or is the only option is using workers/functions in order to use those vars without exposing on the client?
1 replies
CDCloudflare Developers
Created by bkyerv on 1/29/2023 in #workers-help
env variables get wiped out during deploying changes via cli (i.e. wrangler publish)
I noticed that the env variables I have set up for the worker via the dashboard get deleted every time I deploy changes to the worker vie cli using wrangler publish. Is it an expected behavior?
2 replies