dog1283
CDCloudflare Developers
•Created by dog1283 on 7/7/2024 in #workers-help
D1 is empty
Hi All, I am facing an issue using D1 locally. The issue is my worker cannot see any of the DB objects I have created.
First, I setup my DB with some DDL:
wrangler d1 execute appdb-dev --local --file=./1.sql
Then I can query the DB:
wrangler d1 execute appdb-dev --local --command="SELECT * FROM User" // works
However, when I try to access my local d1 instance in the worker, it can't find any tables. It is obviously looking at some other local instance, but I can't find any way to list the local instances, or don't know the commands to understand whether I am looking at the right one.
Any ideas? Wrangler.toml below:
name = "app-services"
compatibility_date = "2023-12-01"
route = "api.myapp.app/*"
compatibility_flags = ["nodejs_compat"]
[vars]
LOG_LEVEL="debug"
TEST_MODE="TRUE"
kv_namespaces = [
{ binding = "MYAPP_TOKENS", preview_id = "###", id = "###" },
]
[[d1_databases]]
binding = "DB"
database_name = "appdb-dev"
database_id = "###"
preview_database_id = "appdb-dev"
[env.dev]
route = "dev-api.myapp.app
1 replies
CDCloudflare Developers
•Created by dog1283 on 6/22/2024 in #workers-help
Excluding Tests
Hi All. I am building a service with Workers and I have my tests in a subfolder of each controller "{controller_name}/specs". I am concerned about them bloating the package when I deploy to production. Does anyone know the correct and preferred way to exclude them from the production build?
4 replies
CDCloudflare Developers
•Created by dog1283 on 3/31/2024 in #workers-help
Custom Routes - Best Practice for Workers as Microservices
Hi all - I am looking for someone to explain the best practice around setting up workers and domains. I am building a saas app with individual services. I have an auth service, data service, etc... I want to have them all sit on api.myapp.app/auth, api.myapp.app/data. I also want api-dev, api-stage subdomains. I have tried to assign a custom route to the service, but it doesn't work and in a way I am not surprised, because I don't have anything anchoring to my subdomain in the way I would have Nginx or even a load balancer in AWS. So, the question is, is there a way of having each service sit on a subroute of api.myapp.app, or do I need to setup a worker to act as a proxy for the other individual services, with the custom domain attached to it? My reticence with this is because every request I receive will essentially invoke two worker calls when it really should only need one. I have to believe there is a better way to do this! Thanks for all advice
4 replies