Options
All
  • Public
  • Public/Protected
  • All
Menu

Module lib/utils/http

Index

Variables

Const KoaHelpers

KoaHelpers: { noop: (ctx: Context, next: Next) => Promise<any> } = ...

A few Koa helper function/middlewares

Type declaration

  • noop: (ctx: Context, next: Next) => Promise<any>
      • (ctx: Context, next: Next): Promise<any>
      • Parameters

        • ctx: Context
        • next: Next

        Returns Promise<any>

Functions

parseAcceptLanguage

  • parseAcceptLanguage(input?: string, supportedLanguages?: string[]): string
  • Parses the accept-language header, and returns the most appropriate supported language

     parseAcceptLanguage('zh_tw;q=0.9, en;q=0.8', ['en', 'zh_tw']) // => 'zh_tw'
    
    export

    Parameters

    • input: string = ""
    • supportedLanguages: string[] = ...

    Returns string

parseBearer

  • parseBearer(header: string): string | null

prefixProtocol

  • prefixProtocol(endpoint: string, protocol?: string): string
  • Adds https:// at the beginning of a URL if it isn't already there

    export

    Parameters

    • endpoint: string
    • protocol: string = 'https'

    Returns string

readBearer

  • readBearer(ctx: Koa.Context): string | null
  • Returns the bearer token found in the headers, or null

    export

    Parameters

    • ctx: Koa.Context

    Returns string | null

Generated using TypeDoc