Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IMeshRequest

Wrapper for the express.Request. We can use them to add properties to the request.

Hierarchy

  • Request
    • IMeshRequest

Implements

  • EventEmitter
  • ReadableStream

Index

Constructors

constructor

Properties

accepted

accepted: MediaType[]

Return an array of Accepted media types ordered from highest quality to lowest.

acceptedCharsets

acceptedCharsets: any[]

Return an array of Accepted charsets ordered from highest quality to lowest.

Examples:

Accept-Charset: iso-8859-5;q=.2, unicode-1-1;q=0.8
['unicode-1-1', 'iso-8859-5']

acceptedLanguages

acceptedLanguages: any[]

Return an array of Accepted languages ordered from highest quality to lowest.

Examples:

Accept-Language: en;q=.5, en-us
['en-us', 'en']

authenticatedUser

authenticatedUser: any

body

body: any

connection

connection: Socket

cookies

cookies: any

fresh

fresh: boolean

Check if the request is fresh, aka Last-Modified and/or the ETag still match.

headers

headers: object

Type declaration

  • [key: string]: string

host

host: string
deprecated

Use hostname instead.

hostname

hostname: string

Parse the "Host" header field hostname.

httpVersion

httpVersion: string

ip

ip: string

Return the remote address, or when "trust proxy" is true return the upstream addr.

ips

ips: string[]

When "trust proxy" is true, parse the "X-Forwarded-For" ip address list.

For example if the value were "client, proxy1, proxy2" you would receive the array ["client", "proxy1", "proxy2"] where "proxy2" is the furthest down-stream.

meshConfig

meshConfig: MeshConfig

method

method: string

originalUrl

originalUrl: string

params

params: any

path

path: string

Short-hand for url.parse(req.url).pathname.

protocol

protocol: string

Return the protocol string "http" or "https" when requested with TLS. When the "trust proxy" setting is enabled the "X-Forwarded-Proto" header field will be trusted. If you're running behind a reverse proxy that supplies https for you this may be enabled.

query

query: any

rawHeaders

rawHeaders: string[]

rawTrailers

rawTrailers: any

readable

readable: boolean

requestedNode

requestedNode: IMeshNode<any>

route

route: any

secure

secure: boolean

Short-hand for:

req.protocol == 'https'

Optional session

session: Session

signedCookies

signedCookies: any

socket

socket: Socket

stale

stale: boolean

Check if the request is stale, aka "Last-Modified" and / or the "ETag" for the resource has changed.

Optional statusCode

statusCode: number

Only valid for response obtained from http.ClientRequest.

Optional statusMessage

statusMessage: string

Only valid for response obtained from http.ClientRequest.

subdomains

subdomains: string[]

Return subdomains as an array.

Subdomains are the dot-separated parts of the host before the main domain of the app. By default, the domain of the app is assumed to be the last two parts of the host. This can be changed by setting "subdomain offset".

For example, if the domain is "tobi.ferrets.example.com": If "subdomain offset" is not set, req.subdomains is ["ferrets", "tobi"]. If "subdomain offset" is 3, req.subdomains is ["tobi"].

trailers

trailers: any

url

url: string

user

user: any

xhr

xhr: boolean

Check if the request was an XMLHttpRequest.

Methods

_read

  • _read(size: number): void

accepts

  • accepts(type: string): string
  • accepts(type: string[]): string
  • Check if the given type(s) is acceptable, returning the best match when true, otherwise undefined, in which case you should respond with 406 "Not Acceptable".

    The type value may be a single mime type string such as "application/json", the extension name such as "json", a comma-delimted list such as "json, html, text/plain", or an array ["json", "html", "text/plain"]. When a list or array is given the best match, if any is returned.

    Examples:

    // Accept: text/html
    req.accepts('html');
    // => "html"
    
    // Accept: text/*, application/json
    req.accepts('html');
    // => "html"
    req.accepts('text/html');
    // => "text/html"
    req.accepts('json, text');
    // => "json"
    req.accepts('application/json');
    // => "application/json"
    
    // Accept: text/*, application/json
    req.accepts('image/png');
    req.accepts('png');
    // => undefined
    
    // Accept: text/*;q=.5, application/json
    req.accepts(['html', 'json']);
    req.accepts('html, json');
    // => "json"
    

    Parameters

    • type: string

    Returns string

  • Parameters

    • type: string[]

    Returns string

acceptsCharset

  • acceptsCharset(charset: string): boolean

acceptsLanguage

  • acceptsLanguage(lang: string): boolean

addListener

  • addListener(event: string, listener: Function): EventEmitter

clearCookie

  • clearCookie(name: string, options?: any): Response

emit

  • emit(event: string, ...args: any[]): boolean

get

  • get(name: string): string
  • Return request header.

    The Referrer header field is special-cased, both Referrer and Referer are interchangeable.

    Examples:

    req.get('Content-Type');
    // => "text/plain"
    
    req.get('content-type');
    // => "text/plain"
    
    req.get('Something');
    // => undefined
    

    Aliased as req.header().

    Parameters

    • name: string

    Returns string

header

  • header(name: string): string

is

  • is(type: string): boolean
  • Check if the incoming request contains the "Content-Type" header field, and it contains the give mime type.

    Examples:

     // With Content-Type: text/html; charset=utf-8
     req.is('html');
     req.is('text/html');
     req.is('text/*');
     // => true
    
     // When Content-Type is application/json
     req.is('json');
     req.is('application/json');
     req.is('application/*');
     // => true
    
     req.is('html');
     // => false
    

    Parameters

    • type: string

    Returns boolean

listeners

  • listeners(event: string): Function[]

on

  • on(event: string, listener: Function): EventEmitter

once

  • once(event: string, listener: Function): EventEmitter

param

  • param(name: string, defaultValue?: any): string
  • Return the value of param name when present or defaultValue.

    • Checks route placeholders, ex: /user/:id
    • Checks body params, ex: id=12, {"id":12}
    • Checks query string params, ex: ?id=12

    To utilize request bodies, req.body should be an object. This can be done by using the connect.bodyParser() middleware.

    Parameters

    • name: string
    • Optional defaultValue: any

    Returns string

pause

  • pause(): void

pipe

  • pipe<T>(destination: T, options?: object): T

push

  • push(chunk: any, encoding?: string): boolean

range

  • range(size: number): any[]
  • Parse Range header field, capping to the given size.

    Unspecified ranges such as "0-" require knowledge of your resource length. In the case of a byte range this is of course the total number of bytes. If the Range header field is not given null is returned, -1 when unsatisfiable, -2 when syntactically invalid.

    NOTE: remember that ranges are inclusive, so for example "Range: users=0-3" should respond with 4 users when available, not 3.

    Parameters

    • size: number

    Returns any[]

read

  • read(size?: number): string | Buffer

removeAllListeners

  • removeAllListeners(event?: string): EventEmitter

removeListener

  • removeListener(event: string, listener: Function): EventEmitter

resume

  • resume(): void

setEncoding

  • setEncoding(encoding: string): void

setMaxListeners

  • setMaxListeners(n: number): void

setTimeout

  • setTimeout(msecs: number, callback: Function): Timer

unpipe

  • unpipe<T>(destination?: T): void

unshift

  • unshift(chunk: string): void
  • unshift(chunk: Buffer): void

wrap

  • wrap(oldStream: ReadableStream): ReadableStream

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string): number

Generated using TypeDoc