MCPcopy
hub / github.com/tinyhttp/tinyhttp / sendStream

Function sendStream

packages/markdown/src/index.ts:20–34  ·  view source on GitHub ↗
(
  path: string,
  markedOptions: MarkedOptions,
  req: Request,
  res: Response,
  caching: Caching | false
)

Source from the content-addressed store, hash-verified

18 NodeJS.WritableStream
19
20const sendStream = async (
21 path: string,
22 markedOptions: MarkedOptions,
23 req: Request,
24 res: Response,
25 caching: Caching | false
26) => {
27 const file = await readFile(path)
28
29 if (caching) enableCaching(res, caching)
30
31 res.setHeader('Content-Type', 'text/html; charset=utf-8')
32
33 send(req, res)(md(file.toString(), markedOptions))
34}
35
36export const markdownStaticHandler = (dir?: string, opts: MarkdownServerHandlerOptions = {}) => async <
37 Req extends Request = Request,

Callers 1

markdownStaticHandlerFunction · 0.85

Calls 2

enableCachingFunction · 0.90
sendFunction · 0.90

Tested by

no test coverage detected