What Goribu configures
- Built-in provisioning: Goribu provisions one D1 database through
database: { type: "d1", name }. - External databases: Goribu has no configuration fields or automatic provisioning for PostgreSQL, MySQL, or Hyperdrive.
Hyperdrive integration is not available in the current Goribu configuration API. Do not add a made-up hyperdrive field or edit generated Wrangler files to work around it.
Use a provider's HTTP API
A service with an HTTPS API can be called from a handler using fetch. Keep its credentials in server environment values. This example assumes your service accepts a bearer token and returns JSON:
export type CatalogEnv = {
CATALOG_API_URL: string;
CATALOG_API_TOKEN: string;
};
// Adapt this path and response handling to your provider's documented API.
export async function readProducts(env: CatalogEnv): Promise<unknown> {
const response = await fetch(new URL("/products", env.CATALOG_API_URL), {
headers: { Authorization: `Bearer ${env.CATALOG_API_TOKEN}` },
});
if (!response.ok) throw new Error("The catalog request failed.");
return response.json();
}
// Adapt this path and response handling to your provider's documented API.
export async function readProducts(env) {
const response = await fetch(new URL("/products", env.CATALOG_API_URL), {
headers: { Authorization: `Bearer ${env.CATALOG_API_TOKEN}` },
});
if (!response.ok) throw new Error("The catalog request failed.");
return response.json();
}
import type { Handler } from "goribu/server";
import { readProducts } from "../lib/catalog.server";
import type { CatalogEnv } from "../lib/catalog.server";
// Only return fields that this endpoint is allowed to expose.
export const GET: Handler<Record<string, unknown>, CatalogEnv> = async (req, res) => {
const products = await readProducts(req.env);
return res.json(products);
};
import { readProducts } from "../lib/catalog.server";
// Only return fields that this endpoint is allowed to expose.
export const GET = async (req, res) => {
const products = await readProducts(req.env);
return res.json(products);
};
- Environment values: Set
CATALOG_API_URLandCATALOG_API_TOKENin.envlocally and.env.productionfor deployment. - Provider contract: The provider controls its endpoint, authentication, validation, consistency, and errors. Adapt the helper to those rules.
Using an SDK or query builder
- Runtime support: Check that a library supports Cloudflare Workers. A Node.js driver is not automatically compatible.
- Service ownership: Goribu does not create a connection pool or manage an external service's schema.
- D1 integrations:
req.d1.sessionprovides the request's session while preserving Goribu's default consistency behavior. - Raw D1 binding:
req.d1.bindingexposes the raw binding when an integration specifically requires it. See D1.
Keep the boundary clear
Place private clients and credentials in server-only modules outside src/routes/. Import them from handlers, and send only the data needed by the page through res.render().
Use your provider's migration and deployment tools for its database. Goribu's migration commands apply only to D1.