Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Correct parseTemplate type, and requestFragment type and initialisation #328

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ declare class Tailor extends EventEmitter {
constructor(options?: {
amdLoaderUrl?: string
, fetchContext?: (req: IncomingMessage) => Promise<object>
, fetchTemplate?: (req: IncomingMessage, parseTemplate: ParseTemplateFunction) => Promise<any>
, fetchTemplate?: (req: IncomingMessage, parseTemplate: ReturnType<ParseTemplateFunction>) => Promise<any>
, filterRequestHeaders?: (attributes: Attributes, req: IncomingMessage) => object
, filterResponseHeaders?: (attributes: Attributes, res: ServerResponse) => object
, fragmentTag?: string
Expand All @@ -39,7 +39,7 @@ declare class Tailor extends EventEmitter {
, maxAssetLinks?: number
, pipeAttributes?: (attributes: Attributes) => object
, pipeInstanceName?: string
, requestFragment?: (filterHeaders: (attributes: Attributes, req: IncomingMessage) => object, url: Url, attributes: Attributes, req: IncomingMessage, span?: Span) => Promise<ServerResponse>
, requestFragment?: (filterHeaders: (attributes: Attributes, req: IncomingMessage) => object) => (url: string, attributes: Attributes, req: IncomingMessage, span?: Span) => Promise<IncomingMessage>
, templatesPath?: string
, tracer?: Tracer
})
Expand All @@ -59,8 +59,8 @@ interface Attributes {

type ParseTemplateFunction = (handledTags: string[], insertBeforePipeTags: string[]) => (
baseTemplate: string,
childTemplate: string,
fullRendering: boolean,
childTemplate?: string,
fullRendering?: boolean,
) => Promise<any>;


6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,18 @@ module.exports = class Tailor extends EventEmitter {
fragmentTag: 'fragment',
handledTags: [],
handleTag: () => '',
requestFragment: requestFragment(filterRequestHeaders),
requestFragment,
pipeInstanceName: 'Pipe',
pipeDefinition: pipeChunk,
pipeAttributes: getPipeAttributes
},
options
);

requestOptions.requestFragment = requestOptions.requestFragment(
filterRequestHeaders
);

initTracer(options.tracer);

requestOptions.parseTemplate = parseTemplate(
Expand Down