dimah-s3v0.4.1

Composition

How plugin hooks and your config hooks run together.

Plugins and your own hooks can share the same lifecycle slot (e.g. upload.presignGuard). They merge automatically — you do not replace plugin hooks when you add yours.

Merge order

  1. Plugin hooks — first, in plugins array order
  2. Your hooks on dimahS3() config — last

Example: with db() registered, its ownership guard runs before your quota check.

import { dimahS3, chainHooks } from "@dimah-s3/server";
import { db } from "@dimah-s3/db";

export const s3 = dimahS3({
  plugins: [db({ client: dimahS3Db, resolveScope })],
  upload: {
    enabled: true,
    presignGuard: quotaGuard, // after the db plugin's guard
  },
});

chainHooks

Stack several user hooks on one slot:

upload: {
  enabled: true,
  presignGuard: chainHooks(quotaGuard, rateLimitGuard),
},

Plugin hooks still run before the chained user hooks.

On this page