vanpana
vanpana
CDCloudflare Developers
Created by vanpana on 12/27/2024 in #workers-help
Knex doesn't work on Workers
Using the same config that I'm using in my express module, I can't get Knex (with 'pg') working due to the following error:
TypeError: this.driver.Client is not a constructor
at Client_PG._acquireOnlyConnection (file:///.../node_modules/knex/lib/dialects/postgres/index.js:82:24)
at Client_PG.acquireRawConnection (file:///.../node_modules/knex/lib/dialects/postgres/index.js:100:17)
at create (file:///.../node_modules/knex/lib/client.js:264:39)
TypeError: this.driver.Client is not a constructor
at Client_PG._acquireOnlyConnection (file:///.../node_modules/knex/lib/dialects/postgres/index.js:82:24)
at Client_PG.acquireRawConnection (file:///.../node_modules/knex/lib/dialects/postgres/index.js:100:17)
at create (file:///.../node_modules/knex/lib/client.js:264:39)
Internally, _acquireOnlyConnection does a require('pg');. Moreover, their Client class uses EventEmitter, but I am using compatibility_flags = ["nodejs_compat"] What could the issue be? I saw an article saying there's support for knex.
1 replies
CDCloudflare Developers
Created by vanpana on 12/24/2024 in #workers-help
"crypto" package inconsistencies
Hey, In my worker, as a middleware, I'm trying to validate a JWT that is being generated from Auth0. Since I have implemented this check in the express service that's running parallel to the worker, I wanted to reuse as much logic as possible. It's not possible to take advantage of the expressjwt middleware since it uses Express-specific types, so I decided to take their code and adapt it to a Worker middleware, but I have noticed inconsistencies in the crypto package, since I'm using the same config, but I am getting different results. The snippet that I will show is based on https://github.com/auth0/express-jwt/blob/129138815162b00b8017e6944f7fc6f3c5776ded/src/index.ts, but I'll skip the boring parts:
4 replies