Also wrangler defaults to 3.0.0 after installing, should I update to 3.10.1?
Also wrangler defaults to 3.0.0 after installing, should I update to 3.10.1?
Postgres.js 3.4.0
pg driver, but if we're using @neondatabase/serverless or similar I'd expect their optimizations to reduce round trips would make it closer at leastimport { Client } from 'pg';
import { Hono, MiddlewareHandler } from 'hono';
type Bindings = {
HYPERDRIVE: Hyperdrive;
};
const app = new Hono<{
Bindings: Bindings;
Variables: {
DB: Client;
};
}>();
const dbMiddleware: MiddlewareHandler = async (c, next) => {
c.set('DB', new Client({ connectionString: c.env.HYPERDRIVE.connectionString }));
await next();
};
app.get('/', dbMiddleware, async (c) => {
try {
// Connect to our database
await c.var.DB.connect();
// Test query
let result = await c.var.DB.query({ text: 'SELECT * FROM pg_tables' });
// Return result rows as JSON
return c.json(result);
} catch (e) {
console.log(e);
return Response.json({ error: JSON.stringify(e) }, { status: 500 });
}
});
export default app;