identity
identity
CDCloudflare Developers
Created by identity on 7/25/2023 in #workers-help
Is a worker well suited for streaming chatGPT responses?
I want to stream responses back to users using Web Streams API in a worker. I'm on a free plan at present which doesn't allow workers running for long in any way. Do you think workers are better suited for immediate responses instead of text streaming cases like mine?
4 replies
CDCloudflare Developers
Created by identity on 7/9/2023 in #workers-help
How to deploy to preview
This is how I tried to deploy but it still gets deployed to prod: wrangler pages deploy --env preview --project-name demo ...
1 replies
CDCloudflare Developers
Created by identity on 7/1/2023 in #workers-help
how to read files without fs
I have code like this to run all sql migeration files:
const dir = new URL('migrations', import.meta.url);

for (const file of fs.readdirSync(dir)) {}
const dir = new URL('migrations', import.meta.url);

for (const file of fs.readdirSync(dir)) {}
given fs is not available, how can i accomplish the same.
2 replies
CDCloudflare Developers
Created by identity on 7/1/2023 in #workers-help
how to run d1 locally when running project with proxy
i want to run my worker and d1 locally. here's how i want to run it wrangler pages dev --local --d1=DB --compatibility-date=2023-06-17 --proxy 5173 -- pnpm dev but the DB is not available. that way. if i tried running vite build --watch and point wrangler to build folder - that works but it takes too long to see coding changes. i can't bring sqlite libs as they depend on node. i am stuck. isn't there a way that i can set up my env so that i can access the DB but at the same time not slow down development while waiting for vite to rebuild?
2 replies
CDCloudflare Developers
Created by identity on 6/17/2023 in #workers-help
How to dynamically import json
Example:
import countries from 'i18n-iso-countries';
countries.registerLocale(await import(`i18n-iso-countries/langs/${"en"}.json`));
return json(countries.getNames("en"));
import countries from 'i18n-iso-countries';
countries.registerLocale(await import(`i18n-iso-countries/langs/${"en"}.json`));
return json(countries.getNames("en"));
${"en"} will break it - but if i put 'en' directly it works. are dynamic import not supported?
9 replies