Rename factory method, fix readme.

This commit is contained in:
SukantGujar 2019-03-12 10:53:04 +05:30
parent fb8b4854ae
commit 00cb4cdb47
4 changed files with 11 additions and 11 deletions

View File

@ -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:

View File

@ -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 {

View File

@ -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;

View File

@ -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";