Options
All
  • Public
  • Public/Protected
  • All
Menu

@alterior/web-server

Index

Type aliases

CertAttributes

CertAttributes: { name?: string; shortName?: string; value: string }[]

EncodingType

EncodingType: "json" | "raw"

MiddlewareDefinition

MiddlewareDefinition: Function | express.RequestHandler | []

Protocol

Protocol: "h2" | "spdy/3.1" | "spdy/3" | "spdy/2" | "http/1.1" | "http/1.0"

RestClient

RestClient<T>: {}

Type parameters

  • T

Type declaration

Variables

Let CONTROLLER_CLASSES

CONTROLLER_CLASSES: any[] = []

Const Controller

Controller: AnnotationDecorator<[string, ControllerOptions]> = ControllerAnnotation.decorator()

Mark a class as representing an Alterior controller.

param

The route path prefix that all routes within this controller will fall within.

param

Const Middleware

Middleware: AnnotationDecorator<[any]> = MiddlewareAnnotation.decorator()

Const WebService

WebService: WebServiceDecorator = <any>WebServiceAnnotation.decorator({validTargets: [ 'class' ],factory: (site, options : WebServiceOptions) => {@Module({imports: [ LoggingModule ],providers: [ ExpressEngine ]})class WebServerModule {constructor(private app : Application,private rolesService : RolesService,private logger : Logger) {}altOnInit() {let webserver : WebServer;webserver = new WebServer(this.app.runtime.injector, options.server, this.logger, this.app.options);let allRoutes = [];let serviceInstance = new ControllerInstance(webserver,site.target,webserver.injector,allRoutes,undefined,true);serviceInstance.initialize();serviceInstance.mount(webserver);if (webserver.options.defaultHandler !== null) {webserver.engine.addAnyRoute(ev => {if (webserver.options.defaultHandler)webserver.options.defaultHandler(ev);elseev.response.status(404).send({ error: 'not-found' });});}this.rolesService.registerRole({identifier: 'web-server',instance: this,name: 'Web Server',summary: 'Starts a web server backed by the controllers configured in the module tree',start: async () => {webserver.start();serviceInstance.start();},stop: async () => {webserver.stop();serviceInstance.stop();}})}}options = Object.assign({}, options);if (!options.imports)options.imports = [];options.imports.push(WebServerModule);Controller('', { group: 'service' })(site.target);Module(options)(site.target);AppOptions(options)(site.target);Service({ compiler: WebServiceCompiler })(site.target);return new WebServiceAnnotation(options);}})

Used to decorate a class which represents a REST service. Such a class is both an Alterior module and an Alterior controller, meaning it can both act as the entry module of an Alterior application as well as define REST routes using the @alterior/web-server @Get()/@Post()/etc decorators.

Functions

Body

  • Body(): (target: any, ...args: any[]) => void
  • Apply to a parameter to indicate that it represents the body of the request.

    Returns (target: any, ...args: any[]) => void

      • (target: any, ...args: any[]): void
      • Parameters

        • target: any
        • Rest ...args: any[]

        Returns void

Delete

  • Delete(path?: string, options?: RouteOptions): (Anonymous function)

Get

  • Get(path?: string, options?: RouteOptions): (Anonymous function)

Mount

  • Mount(path?: string, options?: MountOptions): (Anonymous function)

Options

  • Options(path?: string, options?: RouteOptions): (Anonymous function)

Patch

  • Patch(path?: string, options?: RouteOptions): (Anonymous function)

PathParam

  • PathParam(name?: string): (target: any, ...args: any[]) => void
  • Apply to a parameter to indicate that it represents a path parameter (ie 'thing' in /hello/:thing)

    Parameters

    • Optional name: string

    Returns (target: any, ...args: any[]) => void

      • (target: any, ...args: any[]): void
      • Parameters

        • target: any
        • Rest ...args: any[]

        Returns void

Post

  • Post(path?: string, options?: RouteOptions): (Anonymous function)

Put

  • Put(path?: string, options?: RouteOptions): (Anonymous function)

QueryParam

  • QueryParam(name: string, options?: QueryParamOptions): (target: any, ...args: any[]) => void
  • Apply to a parameter to indicate that it represents a query parameter (ie foo in /bar?foo=1)

    Parameters

    Returns (target: any, ...args: any[]) => void

      • (target: any, ...args: any[]): void
      • Parameters

        • target: any
        • Rest ...args: any[]

        Returns void

Request

  • Request(name?: string): (target: any, ...args: any[]) => void
  • Apply to a parameter to indicate that it represents a session parameter (ie foo in /bar?foo=1)

    deprecated

    Use WebEvent.current. Will be removed in 4.0.0

    Parameters

    • Optional name: string

    Returns (target: any, ...args: any[]) => void

      • (target: any, ...args: any[]): void
      • Parameters

        • target: any
        • Rest ...args: any[]

        Returns void

Route

  • Route(method: string, path?: string, options?: RouteOptions): (Anonymous function)

SessionValue

  • SessionValue(name?: string): (target: any, ...args: any[]) => void
  • Apply to a parameter to indicate that it represents a session parameter (ie foo in /bar?foo=1)

    deprecated

    Use the Session class

    Parameters

    • Optional name: string

    Returns (target: any, ...args: any[]) => void

      • (target: any, ...args: any[]): void
      • Parameters

        • target: any
        • Rest ...args: any[]

        Returns void

accessControl

  • accessControl(req: express.Request, res: express.Response, next: any): void

main

  • main(): Promise<void>

prepareMiddleware

  • prepareMiddleware(injector: Injector, middleware: any): any

runTest

  • runTest(name: any, discard?: boolean): Promise<void>

teststrap

Generated using TypeDoc