@teikyo/hozon
v0.4.0
Published
Hozon database plugin for Sozai HTTP servers
Readme
@teikyo/hozon
Hozon database plugin for @sozai/http-server. It provides a HozonDB to dependent plugins, reports readiness from a trivial query and closes the database after its dependents.
Install
pnpm add @teikyo/hozon @sozai/http-server honoUsage
Plugin name: hozon:db (exported as HOZON_DB).
import { createServer } from '@sozai/http-server'
import { hozonDBPlugin } from '@teikyo/hozon'
const server = await createServer({
plugins: [hozonDBPlugin({ db: './app.db', tablePrefix: 'app_' })],
})Dependent plugins list HOZON_DB in dependsOn and call ctx.use(HOZON_DB) to register stores.
Options
| Option | Type | Description |
| --- | --- | --- |
| db | HozonDBInput | An adapter, a file path, :memory:, a postgres:// URL or an existing HozonDB. An existing HozonDB is used as is -- tablePrefix and the logger are not applied -- and the plugin still closes it on shutdown. |
| tablePrefix | string (optional) | Prefix applied to every table created through the database. |
