Chinoman10
Chinoman10
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
Oh since I never heard of it I just kinda ignored it 😅🙏
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
So I'm guessing you didn't know that pages dev did the bindings for you? How were you accessing the DO from within the Pages then?
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
You can see I'm getting the OAUTH_KV from env, which comes from the request.
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
No description
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
As long as they are declared in the wrangler.toml, yup!
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
Well the binding is done with wrangler, which I've posted. Then whenever there's a GET/POST request, the ctx is provided which has the request, the env, the waitUntil util function, etc. The env has the bindings.
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
Sure, I'll try that tomorrow morning 👍
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
I'm not sure I follow? What's the issue with using D1 or KV without a framework? All the code is in the 'functions' folder, which is kinda like a Worker, so 🤷‍♂️ Everything works fine. KV's are a bit wonky on localhost, but D1's work magnificently well. Makes me love DB's when I previously hated their guts (got PTSD from prev. jobs).
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
This is the pages wrangler:
# Generated by Wrangler on Tue Apr 16 2024 16:41:52 GMT+0200 (Central European Summer Time)
name = "client-caoba-hotels"
pages_build_output_dir = "_site"
compatibility_date = "2024-06-30"

[dev]
port = 3000

[[kv_namespaces]]
binding = "OAUTH_KV"
id = "617510114b886"

[[d1_databases]]
binding = "RESERVATIONS_DB"
database_name = "caoba-stg"
database_id = "d339a2acae2e1"
preview_database_id = "d339a396acae2e1"

[[durable_objects.bindings]]
name = "ALARM_DO"
class_name = "AlarmDO"
script_name = "alarm-durable-object"

[env.production]
compatibility_date = "2024-06-30"

[env.production.vars]
JEKYLL_ENV = "production"
ENVIRONMENT = "production"
# ... other vars

[[env.production.d1_databases]]
binding = "RESERVATIONS_DB"
database_name = "caoba-prd"
database_id = "d339acae2e1"

[env.preview]
[env.preview.vars]
JEKYLL_ENV = "staging"
ENVIRONMENT = "preview"

[[env.preview.d1_databases]]
binding = "RESERVATIONS_DB"
database_name = "caoba-stg"
database_id = "d33e2e1"
# Generated by Wrangler on Tue Apr 16 2024 16:41:52 GMT+0200 (Central European Summer Time)
name = "client-caoba-hotels"
pages_build_output_dir = "_site"
compatibility_date = "2024-06-30"

[dev]
port = 3000

[[kv_namespaces]]
binding = "OAUTH_KV"
id = "617510114b886"

[[d1_databases]]
binding = "RESERVATIONS_DB"
database_name = "caoba-stg"
database_id = "d339a2acae2e1"
preview_database_id = "d339a396acae2e1"

[[durable_objects.bindings]]
name = "ALARM_DO"
class_name = "AlarmDO"
script_name = "alarm-durable-object"

[env.production]
compatibility_date = "2024-06-30"

[env.production.vars]
JEKYLL_ENV = "production"
ENVIRONMENT = "production"
# ... other vars

[[env.production.d1_databases]]
binding = "RESERVATIONS_DB"
database_name = "caoba-prd"
database_id = "d339acae2e1"

[env.preview]
[env.preview.vars]
JEKYLL_ENV = "staging"
ENVIRONMENT = "preview"

[[env.preview.d1_databases]]
binding = "RESERVATIONS_DB"
database_name = "caoba-stg"
database_id = "d33e2e1"
And this is the worker's wrangler.toml:
name = "alarm-durable-object"
main = "src/index.ts"
compatibility_date = "2024-07-12"

[[durable_objects.bindings]]
name = "AlarmDO"
class_name = "AlarmDO"

[[migrations]]
tag = "v1"
new_classes = ["AlarmDO"]
name = "alarm-durable-object"
main = "src/index.ts"
compatibility_date = "2024-07-12"

[[durable_objects.bindings]]
name = "AlarmDO"
class_name = "AlarmDO"

[[migrations]]
tag = "v1"
new_classes = ["AlarmDO"]
I truncated the IDs and removed most vars.
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
No description
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
No description
31 replies
CDCloudflare Developers
Created by Chinoman10 on 7/27/2024 in #durable-objects
I have the weirdest situation going
{
"name": "client-caoba-hotels",
"type": "module",
"workspaces": [
"alarm-durable-object"
],
"scripts": {
"install:dev": "bundle install && bun i",
"build": "bundle exec jekyll build",
"build:dev": "bun run build -- --config _config_dev.yml",
"build:watch": "bundle exec jekyll build --config _config_dev.yml --watch > jekyll.log 2>&1 & echo $! > jekyll.pid",
"predev:no-watch": "bun run build:dev",
"dev:no-watch": "bun run wrangler",
"predev": "bun run build:watch",
"dev": "bun run wrangler",
"dev:do": "bun run wrangler:withDO",
"postdev": "kill -0 $(cat jekyll.pid) 2>/dev/null && (bun run kill:jekyll) || (bun run clean:jekyll && echo 'Jekyll already terminated.')",
"start": "bun run wrangler",
"wrangler": "wrangler pages dev _site",
"prewrangler:withDO": "cd alarm-durable-object && wrangler dev > ../wrangler.log 2>&1 & echo $! > ../wrangler.pid",
"wrangler:withDO": "wrangler pages dev _site --do ALARM_DO=AlarmDO@alarm-durable-object",
"postwrangler:withDO": "kill -0 $(cat wrangler.pid) 2>/dev/null && (bun run kill:wrangler) || (bun run clean:wrangler && echo 'Wrangler already terminated.')",
"kill:jekyll": "kill $(cat jekyll.pid) ; wait $(cat jekyll.pid) 2>/dev/null ; bun run clean:jekyll ; echo 'Done.'",
"kill:wrangler": "kill $(cat wrangler.pid) ; wait $(cat wrangler.pid) 2>/dev/null ; bun run clean:wrangler ; echo 'Done.'",
"clean:jekyll": "rm -f jekyll.pid && rm -f jekyll.log || rm -f wrangler.pid && rm -f wrangler.log",
"clean:wrangler": "rm -f wrangler.pid && rm -f wrangler.log",
"download-db": "wrangler d1 export caoba-stg --output db.sql --remote && wrangler d1 execute RESERVATIONS_DB --local --file db.sql"
},
"dependencies": {
"@cloudflare/workers-types": "^4.20240712.0",
"@paralleldrive/cuid2": "^2.2.2",
"stripe": "^16.1.0",
"typescript": "^5.5.2",
"valibot": "^0.35.0"
},
"devDependencies": {
"@types/bun": "^1.1.6",
"wrangler": "3.67.1"
}
}
{
"name": "client-caoba-hotels",
"type": "module",
"workspaces": [
"alarm-durable-object"
],
"scripts": {
"install:dev": "bundle install && bun i",
"build": "bundle exec jekyll build",
"build:dev": "bun run build -- --config _config_dev.yml",
"build:watch": "bundle exec jekyll build --config _config_dev.yml --watch > jekyll.log 2>&1 & echo $! > jekyll.pid",
"predev:no-watch": "bun run build:dev",
"dev:no-watch": "bun run wrangler",
"predev": "bun run build:watch",
"dev": "bun run wrangler",
"dev:do": "bun run wrangler:withDO",
"postdev": "kill -0 $(cat jekyll.pid) 2>/dev/null && (bun run kill:jekyll) || (bun run clean:jekyll && echo 'Jekyll already terminated.')",
"start": "bun run wrangler",
"wrangler": "wrangler pages dev _site",
"prewrangler:withDO": "cd alarm-durable-object && wrangler dev > ../wrangler.log 2>&1 & echo $! > ../wrangler.pid",
"wrangler:withDO": "wrangler pages dev _site --do ALARM_DO=AlarmDO@alarm-durable-object",
"postwrangler:withDO": "kill -0 $(cat wrangler.pid) 2>/dev/null && (bun run kill:wrangler) || (bun run clean:wrangler && echo 'Wrangler already terminated.')",
"kill:jekyll": "kill $(cat jekyll.pid) ; wait $(cat jekyll.pid) 2>/dev/null ; bun run clean:jekyll ; echo 'Done.'",
"kill:wrangler": "kill $(cat wrangler.pid) ; wait $(cat wrangler.pid) 2>/dev/null ; bun run clean:wrangler ; echo 'Done.'",
"clean:jekyll": "rm -f jekyll.pid && rm -f jekyll.log || rm -f wrangler.pid && rm -f wrangler.log",
"clean:wrangler": "rm -f wrangler.pid && rm -f wrangler.log",
"download-db": "wrangler d1 export caoba-stg --output db.sql --remote && wrangler d1 execute RESERVATIONS_DB --local --file db.sql"
},
"dependencies": {
"@cloudflare/workers-types": "^4.20240712.0",
"@paralleldrive/cuid2": "^2.2.2",
"stripe": "^16.1.0",
"typescript": "^5.5.2",
"valibot": "^0.35.0"
},
"devDependencies": {
"@types/bun": "^1.1.6",
"wrangler": "3.67.1"
}
}
This is how I've done our package.json 😅 bit on the crazy end, but it works (well, except for the DOs I guess).
31 replies