mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-01 04:12:58 +08:00
Rename factory method, fix readme.
This commit is contained in:
parent
fb8b4854ae
commit
00cb4cdb47
14
Readme.md
14
Readme.md
@ -56,12 +56,12 @@ From the `express-file-server` example:
|
||||
};
|
||||
};
|
||||
|
||||
2. In your express code, use `createPartialStreamHandler` factory method to generate an express handler for serving partial content for the route of your choice:
|
||||
2. In your express code, use `createPartialContentHandler` factory method to generate an express handler for serving partial content for the route of your choice:
|
||||
|
||||
import {createPartialStreamHandler} from "express-partial-content";
|
||||
import {createPartialContentHandler} from "express-partial-content";
|
||||
import {logger} from "./logger";
|
||||
|
||||
const handler = createPartialStreamHandler(fileContentProvider, logger);
|
||||
const handler = createPartialContentHandler(fileContentProvider, logger);
|
||||
|
||||
const app = express();
|
||||
const port = 8080;
|
||||
@ -79,9 +79,9 @@ From the `express-file-server` example:
|
||||
|
||||
# Reference
|
||||
|
||||
## createPartialStreamHandler function:
|
||||
## createPartialContentHandler function:
|
||||
|
||||
The package exports `createPartialStreamHandler` factory method.
|
||||
This is a factory method which generates a partial content handler for express routes.
|
||||
|
||||
### Arguments:
|
||||
|
||||
@ -90,11 +90,11 @@ The package exports `createPartialStreamHandler` factory method.
|
||||
|
||||
### Returns:
|
||||
|
||||
- Express Route Handler: `createPartialStreamHandler` returns an express handler which can be mapped to an Express route to serve partial content.
|
||||
- Express Route Handler: `createPartialContentHandler` returns an express handler which can be mapped to an Express route to serve partial content.
|
||||
|
||||
## ContentProvider function:
|
||||
|
||||
This function _needs to be implemented by you_. It's purpose is to fetch and return `Content` object containing necessary metadata and methods to stream the content partially. This method is invoked by the express handler (returned by `createPartialStreamHandler`) on each request.
|
||||
This function _needs to be implemented by you_. It's purpose is to fetch and return `Content` object containing necessary metadata and methods to stream the content partially. This method is invoked by the express handler (returned by `createPartialContentHandler`) on each request.
|
||||
|
||||
### Arguments:
|
||||
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
setContentLengthHeader,
|
||||
setCacheControlHeaderNoCache
|
||||
} from "./utils";
|
||||
export function createPartialStreamHandler(contentProvider: ContentProvider, logger: Logger) {
|
||||
export function createPartialContentHandler(contentProvider: ContentProvider, logger: Logger) {
|
||||
return async function handler(req: Request, res: Response) {
|
||||
let content;
|
||||
try {
|
@ -1,9 +1,9 @@
|
||||
import express from "express";
|
||||
import { createPartialStreamHandler } from "../../index";
|
||||
import { createPartialContentHandler } from "../../index";
|
||||
import { fileContentProvider } from "./fileContentProvider";
|
||||
import { logger } from "./logger";
|
||||
|
||||
const handler = createPartialStreamHandler(fileContentProvider, logger);
|
||||
const handler = createPartialContentHandler(fileContentProvider, logger);
|
||||
|
||||
const app = express();
|
||||
const port = 8080;
|
||||
|
@ -1,6 +1,6 @@
|
||||
export * from "./Content";
|
||||
export * from "./ContentDoesNotExistError";
|
||||
export * from "./ContentProvider";
|
||||
export * from "./createPartialStreamHandler";
|
||||
export * from "./createPartialContentHandler";
|
||||
export * from "./Logger";
|
||||
export * from "./Range";
|
||||
|
Loading…
x
Reference in New Issue
Block a user