That sounds like it should be specific to Enterprise accounts? @Matt
That sounds like it should be specific to Enterprise accounts? @Matt




Postgres.js 3.4.0
import { 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;