Options
All
  • Public
  • Public/Protected
  • All
Menu

@acrontum/moxy

Index

Type aliases

HandlerVariables: Record<string, string | string[]>

Path and query params

LogLevels: "error" | "off" | string
Method: "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace"

Common http verbs

MethodConfig: MethodSettings | string | RequestHandler

Configuration for a method. Would be configured as { get: MethodConfig, post: MethodConfig, ... }

examples

Standard http response: { status: 200, body: { message: 'hello' }, }

Manual request listener method: async (req, res, vars) => res.sendJson({ url: req.url, date: Date.now() }, { status: 201 });

Static file: '/static/:file'

PathConfig: PathSettings & { all?: MethodConfig } & { [ key in Method]?: MethodConfig }

Configuration for a path.

RequestHandler: (req: MoxyRequest, res: MoxyResponse, variables: HandlerVariables, server: MoxyServer) => void

Type declaration

RouteConfig: string | RequestHandler | PathConfig

Configuration for a route.

Routes: Record<string, RouteConfig>

Configuration for multiple routes.

Variables

colours: { blue: string; green: string; majenta: string; none: string; purple: string; red: string; teal: string; yellow: string } = ...

Type declaration

  • blue: string
  • green: string
  • majenta: string
  • none: string
  • purple: string
  • red: string
  • teal: string
  • yellow: string
extToMimeType: Record<string, string> = ...
methodColours: Record<Method, string> = ...

Functions

  • assertNextArg(name: string, argv: string[]): string
  • Parameters

    • name: string
    • argv: string[]

    Returns string

  • formatBody(body: string | Record<string, any> | Buffer): string | Buffer
  • Parameters

    • body: string | Record<string, any> | Buffer

    Returns string | Buffer

  • formatMethod(method: Method): string
  • formatRoutesForPrinting(routes: Routes, expandFunction?: boolean): string
  • formatStatus(status: number): string
  • getId(): string
  • getOption(config: CliConfig, argv?: string[]): number

Generated using TypeDoc