-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
320 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@kopflos-cms/core": patch | ||
--- | ||
|
||
More precise typing of core interfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@kopflos-cms/express": patch | ||
"@kopflos-cms/core": patch | ||
--- | ||
|
||
Adding support for accessing request body |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
export type { KopflosResponse } from './lib/Kopflos.js' | ||
export type { Kopflos, KopflosConfig } from './lib/Kopflos.js' | ||
export type { Kopflos, KopflosConfig, Body, Query } from './lib/Kopflos.js' | ||
export { default } from './lib/Kopflos.js' | ||
export { loadHandler as defaultHandlerLookup } from './lib/handler.js' | ||
export type { ResourceLoader } from './lib/resourceLoader.js' | ||
export type { Handler, SubjectHandler, ObjectHandler } from './lib/handler.js' | ||
export type { Handler, SubjectHandler, ObjectHandler, HandlerArgs } from './lib/handler.js' | ||
export { default as log, logCode } from './lib/log.js' | ||
export type { KopflosEnvironment } from './lib/env/index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Readable } from 'node:stream' | ||
import type { Request } from 'express' | ||
import type { NamedNode } from '@rdfjs/types' | ||
import type { Body } from '@kopflos-cms/core' | ||
import type { Environment } from '@rdfjs/environment/Environment.js' | ||
import type ClownfaceFactory from 'clownface/Factory.js' | ||
import type { Dataset } from '@zazuko/env/lib/DatasetExt.js' | ||
import type { DatasetFactoryExt } from '@zazuko/env/lib/DatasetFactoryExt.js' | ||
import onetime from 'onetime' | ||
|
||
export class BodyWrapper implements Body { | ||
declare dataset: Promise<Dataset> | ||
|
||
constructor(private readonly env: Environment<DatasetFactoryExt | ClownfaceFactory>, private readonly term: NamedNode, private readonly req: Readable & Pick<Request, 'quadStream'>) { | ||
Object.defineProperty(this, 'dataset', { | ||
get: onetime(() => { | ||
this.env.dataset().import(this.quadStream) | ||
}), | ||
}) | ||
} | ||
|
||
get quadStream() { | ||
return this.req.quadStream!() | ||
} | ||
|
||
async pointer() { | ||
return this.env.clownface({ | ||
dataset: await this.dataset, | ||
term: this.term, | ||
}) | ||
} | ||
|
||
get raw() { | ||
return Readable.toWeb(this.req) | ||
} | ||
} |
Oops, something went wrong.