using Mongoose with cloudflare workers?

hey all, i'm trying to create a worker that uses mongodb + mongoose alongside hono, i currently have:
import { Hono } from 'hono';
import { connect } from 'mongoose';

const app = new Hono<{ Bindings: ... } >();
app.use('*', async ctx => {
await connect(ctx.env.MONGO_STRING);
});
import { Hono } from 'hono';
import { connect } from 'mongoose';

const app = new Hono<{ Bindings: ... } >();
app.use('*', async ctx => {
await connect(ctx.env.MONGO_STRING);
});
however, doing this with npx wrangler dev i get the following error:
at null.<anonymous> (file:///home/myproject/worker/src/index.ts:10:8)
at dispatch
(file:///home/myproject/worker/node_modules/hono/dist/compose.js:29:23)
at null.<anonymous>
(file:///home/myproject/worker/node_modules/hono/dist/compose.js:6:12)
at null.<anonymous>
(file:///home/myproject/worker/node_modules/hono/dist/hono-base.js:188:31)
at Hono2.dispatch
(file:///home/myproject/worker/node_modules/hono/dist/hono-base.js:198:5)
at Object.fetch
(file:///home/myproject/worker/node_modules/hono/dist/hono-base.js:201:17)
at __facade_modules_fetch__
(file:///home/myproject/worker/.wrangler/tmp/bundle-7uxxpi/middleware-loader.entry.ts:45:16)
at __facade_invokeChain__
(file:///home/myproject/worker/node_modules/wrangler/templates/middleware/common.ts:53:9)
at Object.next
(file:///home/myproject/worker/node_modules/wrangler/templates/middleware/common.ts:50:11)
at jsonError
(file:///home/myproject/worker/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30)
at null.<anonymous> (file:///home/myproject/worker/src/index.ts:10:8)
at dispatch
(file:///home/myproject/worker/node_modules/hono/dist/compose.js:29:23)
at null.<anonymous>
(file:///home/myproject/worker/node_modules/hono/dist/compose.js:6:12)
at null.<anonymous>
(file:///home/myproject/worker/node_modules/hono/dist/hono-base.js:188:31)
at Hono2.dispatch
(file:///home/myproject/worker/node_modules/hono/dist/hono-base.js:198:5)
at Object.fetch
(file:///home/myproject/worker/node_modules/hono/dist/hono-base.js:201:17)
at __facade_modules_fetch__
(file:///home/myproject/worker/.wrangler/tmp/bundle-7uxxpi/middleware-loader.entry.ts:45:16)
at __facade_invokeChain__
(file:///home/myproject/worker/node_modules/wrangler/templates/middleware/common.ts:53:9)
at Object.next
(file:///home/myproject/worker/node_modules/wrangler/templates/middleware/common.ts:50:11)
at jsonError
(file:///home/myproject/worker/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30)
is this supported at all?
2 Replies
spookily_
spookily_3mo ago
looks like this isn't really a supported use case?
Cyb3r-Jak3
Cyb3r-Jak33mo ago
I believe the only way the MongoDB works is with the Atlas HTTP API