Starting out with workers and bundling code
Hello, we are trying to build a worker using
hono
and sequelize
. It's basically an API that we will call from various locations, to do CRUD ops into a database (aws aurora mysql currently).
Any pointers on how to bundle the code? I've tried to set `type = "webpack" in wrangler.toml but seems like it's deprecated?
Thanks15 Replies
wrangler
can automatically bundle your code for you. Set your main
field to your entrypoint(src/index.ts/js
), and it should auto-bundle it.I do have this set, but for example I get errors like this:
setting node_compat brings a whole lot of other errors
Looks like
sequelize
isn't compatible with Workers. node_compat
can fix some of those issues, but if it requires access to a file system, then it won't work.Hmm any ideas of a package for mysql db's that is compatible?
Hmm I'll take a look into them!
From a quick look, looks like they are some kind of proxy that you have to pay?
Or is just a service that is "also" offered?
Prisma comes with
Data Proxy usage of 3 million CPU ms/mo
, and Planetscale is a Hosted MySQL-compatible database with the following Free Tier:
Seems a bit weird to pay for CF workers and then also pay for another proxy in to access a database that we also pay 🙂
There is also a tutorial to use CF Tunnels for DB Connectivity, but not 100% sure how well it is maintained.
The main thing though is that DBs are made with long-running connections in mind, and thus aren't really architectures for short-lived connections with one or two transactions.
Not sure how tunnel will work with an aurora db in aws :/
There are some that are built from the ground up to be made for serverless workloads(Planetscale, Upscale, etc.), but those aren't just hosted MySQL/Postrgres
Using the Data API for Aurora Serverless v1 - Amazon Aurora
By using the Data API for Aurora Serverless v1 , you can work with a web-services interface to your Aurora Serverless v1 DB cluster. The Data API doesn't require a persistent connection to the DB cluster. Instead, it provides a secure HTTP endpoint and integration with AWS SDKs. You can use the endpoint to run SQL statements without managing con...
I see, maybe I'll check if aws have some sort of package/api for its db
you beat me to it
lol
I don't work with AWS very often, but it looks like this might work?
I'll give it a shot. It's the only thing that I plan to leave to AWS for now.
DNS is already migrating to CF and some of the websites