diff --git a/.changeset/perfect-humans-own.md b/.changeset/perfect-humans-own.md new file mode 100644 index 00000000..b4f4359f --- /dev/null +++ b/.changeset/perfect-humans-own.md @@ -0,0 +1,5 @@ +--- +"@kopflos-cms/core": patch +--- + +Added `handlers.js` module with `getCoreRepresentation` handler diff --git a/packages/core/handlers.ts b/packages/core/handlers.ts new file mode 100644 index 00000000..88023a46 --- /dev/null +++ b/packages/core/handlers.ts @@ -0,0 +1,12 @@ +import { log, type SubjectHandler } from './index.js' + +export function getCoreRepresentation(): SubjectHandler { + log.warn('Using @kopflos-cms/handlers.js#getCoreRepresentation is not equivalent to skipping the handler altogether because it materiliazes the dataset. This is not recommended for large resources.') + + return ({ subject }) => { + return { + status: 200, + body: subject.dataset.toStream(), + } + } +} diff --git a/packages/core/package.json b/packages/core/package.json index d8b535c1..6fd63bea 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -11,6 +11,7 @@ }, "exports": { ".": "./index.js", + "./handlers.js": "./handlers.js", "./env.js": "./lib/env/index.js", "./resourceLoaders.js": "./resourceLoaders.js", "./plugins.js": "./plugins.js",