@types/morgan
- Version 1.9.9
- Published
- 13.9 kB
- 1 dependency
- MIT license
Install
npm i @types/morgan
yarn add @types/morgan
pnpm add @types/morgan
Overview
TypeScript definitions for morgan
Index
Functions
function compile
compile: < Request extends http.IncomingMessage = http.IncomingMessage, Response extends http.ServerResponse = http.ServerResponse>( format: string) => FormatFn<Request, Response>;
Compile a format string in token notation into a format function.
function format
format: { < Request extends http.IncomingMessage = http.IncomingMessage, Response extends http.ServerResponse = http.ServerResponse >( name: string, fmt: string ): Morgan<Request, Response>; < Request extends http.IncomingMessage = http.IncomingMessage, Response extends http.ServerResponse = http.ServerResponse >( name: string, fmt: FormatFn<Request, Response> ): Morgan<Request, Response>;};
Define a named custom format by specifying a format string in token notation.
Define a named custom format by specifying a format function.
function morgan
morgan: typeof morgan;
* Create a new morgan logger middleware function using the given format and options. The format argument may be a string of a predefined name (see below for the names), or a string of a format string containing defined tokens.
Parameter format
Parameter options
* Standard Apache combined log output. :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"
Parameter format
Parameter options
* Standard Apache common log output. :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length]
Parameter format
Parameter options
* Concise output colored by response status for development use. The :status token will be colored red for server error codes, yellow for client error codes, cyan for redirection codes, and uncolored for all other codes. :method :url :status :response-time ms - :res[content-length]
Parameter format
Parameter options
* Shorter than default, also including response time. :remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms
Parameter format
Parameter options
* The minimal output. :method :url :status :res[content-length] - :response-time ms
Parameter format
Parameter options
* Create a new morgan logger middleware function using the given format and options. The format argument may be a custom format function which adheres to the signature.
Parameter format
Parameter options
function token
token: < Request extends http.IncomingMessage = http.IncomingMessage, Response extends http.ServerResponse = http.ServerResponse>( name: string, callback: TokenCallbackFn<Request, Response>) => Morgan<Request, Response>;
Define a custom token which can be used in custom morgan logging formats.
Interfaces
interface Morgan
interface Morgan< Request extends http.IncomingMessage, Response extends http.ServerResponse> {}
Public interface of morgan logger.
method compile
compile: (format: string) => FormatFn<Request, Response>;
Compile a format string in token notation into a format function.
method format
format: { (name: string, fmt: string): Morgan<Request, Response>; (name: string, fmt: FormatFn<Request, Response>): Morgan<Request, Response>;};
Define a named custom format by specifying a format string in token notation.
Define a named custom format by specifying a format function.
method token
token: ( name: string, callback: TokenCallbackFn<Request, Response>) => Morgan<Request, Response>;
Define a custom token which can be used in custom morgan logging formats.
call signature
(format: string, options?: Options<Request, Response>): Handler< Request, Response>;
* Create a new morgan logger middleware function using the given format and options. The format argument may be a string of a predefined name (see below for the names), or a string of a format string containing defined tokens.
Parameter format
Parameter options
call signature
(format: 'combined', options?: Options<Request, Response>): Handler< Request, Response>;
* Standard Apache combined log output. :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"
Parameter format
Parameter options
call signature
(format: 'common', options?: Options<Request, Response>): Handler< Request, Response>;
* Standard Apache common log output. :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length]
Parameter format
Parameter options
call signature
(format: 'dev', options?: Options<Request, Response>): Handler< Request, Response>;
Concise output colored by response status for development use. The :status token will be colored red for server error codes, yellow for client error codes, cyan for redirection codes, and uncolored for all other codes. :method :url :status :response-time ms - :res[content-length]
call signature
(format: 'short', options?: Options<Request, Response>): Handler< Request, Response>;
* Shorter than default, also including response time. :remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms
Parameter format
Parameter options
call signature
(format: 'tiny', options?: Options<Request, Response>): Handler< Request, Response>;
* The minimal output. :method :url :status :res[content-length] - :response-time ms
Parameter format
Parameter options
call signature
( format: FormatFn<Request, Response>, options?: Options<Request, Response>): Handler<Request, Response>;
* Create a new morgan logger middleware function using the given format and options. The format argument may be a custom format function which adheres to the signature.
Parameter format
Parameter options
interface Options
interface Options< Request extends http.IncomingMessage, Response extends http.ServerResponse> {}
* Morgan accepts these properties in the options object.
property buffer
buffer?: boolean | undefined;
* Buffer duration before writing logs to the stream, defaults to false. When set to true, defaults to 1000 ms.
Deprecated
property immediate
immediate?: boolean | undefined;
* Write log line on request instead of response. This means that a requests will be logged even if the server crashes, but data from the response cannot be logged (like the response code).
property stream
stream?: StreamOptions | undefined;
* Output stream for writing log lines, defaults to process.stdout.
Parameter str
method skip
skip: (req: Request, res: Response) => boolean;
* Function to determine if logging is skipped, defaults to false. This function will be called as skip(req, res).
interface StreamOptions
interface StreamOptions {}
method write
write: (str: string) => void;
Output stream for writing log lines.
interface TokenIndexer
interface TokenIndexer< Request extends http.IncomingMessage = http.IncomingMessage, Response extends http.ServerResponse = http.ServerResponse> {}
index signature
[tokenName: string]: TokenCallbackFn<Request, Response>;
Type Aliases
type FormatFn
type FormatFn< Request extends http.IncomingMessage = http.IncomingMessage, Response extends http.ServerResponse = http.ServerResponse> = ( tokens: TokenIndexer<Request, Response>, req: Request, res: Response) => string | undefined | null;
type TokenCallbackFn
type TokenCallbackFn< Request extends http.IncomingMessage = http.IncomingMessage, Response extends http.ServerResponse = http.ServerResponse> = ( req: Request, res: Response, arg?: string | number | boolean) => string | undefined;
Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/morgan
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/morgan)
- HTML<a href="https://www.jsdocs.io/package/@types/morgan"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2880 ms. - Missing or incorrect documentation? Open an issue for this package.