Skip to content

Commit

Permalink
feat: getCoreRepresentation handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Jan 28, 2025
1 parent 78e5dda commit c3eac24
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-humans-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kopflos-cms/core": patch
---

Added `handlers.js` module with `getCoreRepresentation` handler
12 changes: 12 additions & 0 deletions packages/core/handlers.ts
Original file line number Diff line number Diff line change
@@ -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(),
}
}
}

Check warning on line 12 in packages/core/handlers.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/handlers.ts#L1-L12

Added lines #L1 - L12 were not covered by tests
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c3eac24

Please sign in to comment.