Options
All
  • Public
  • Public/Protected
  • All
Menu

External module Decorators

Index

Functions

Application

  • Class Decorator Function

    Creates a runner upon a class. No need to create an object and to serve manually

    example
    
      @Application({
         contentType: 'application/json',
         server: {
             port: 3000,
             maxConnections: 10,
             timeout: 500,
             keepAliveTimeout: 500
         },
         components: [TestComponent],
         middleware: [(request: Request, response: Response) => { }]
      })
      class Test {}
    

    Parameters

    Returns (Anonymous function)

Component

  • Class Decorator Function

    A collection of endpoints. Every endpoints in this will apply the given metadata. Add the class Symbols to the application components array (similar to angular module) to apply them to an application

    example
    
      @Component({
         route: '/api',
         middleware: [(request: Request, response: Response) => { }]
      })
      class Test {}
    

    Parameters

    Returns (Anonymous function)

Delete

  • Since 1.7 Property Decorator Function Works basically like the @Endpoint decorator, but only DELETE requests will be mapped to it. this will enable duplicate routes on different method types

    Parameters

    Returns function

      • (target: Object, key: string): void
      • Parameters

        • target: Object
        • key: string

        Returns void

Endpoint

  • Property Decorator Function

    Creates an endpoint of a function The decorated function need the following index signature otherwise it will throw an error (request: Request, response: Response, next?: Function) (also an index signature fore middlewares) If you pass the next-function and call it, it will get the next function from the route middlewares and abort the current execution

    example
    
      @Component({route: '/api'})
      class Test {
    
         @Endpoint({
             route: '/foo'
             middleware: [(request: request) => request.params['foo'] = foo; ]
         )
         foo(request: Request, response: Response) {
             response
              .status(200)
              .json(request.params.foo)
              .send();
         }
      }
    

    Parameters

    Returns function

      • (target: Object, key: string): void
      • Parameters

        • target: Object
        • key: string

        Returns void

Get

  • Since 1.7 Property Decorator Function Works basically like the @Endpoint decorator, but only GET requests will be mapped to it. this will enable duplicate routes on different method types

    Parameters

    Returns function

      • (target: Object, key: string): void
      • Parameters

        • target: Object
        • key: string

        Returns void

Injectable

  • Class Decorator Function

    Allows to inject dependencies into objects

    example
    
      @Injectable()
      class InjectedDependency {
         public foo = 'foo'
      }
    
      class Target {
         constructor (private foo: InjectedDependency);
    
         getFoosFoo() { return this.foo.foo }
      }
    

    Parameters

    Returns GenericClassDecorator<Instantiable<any>>

Module

  • Class Decorator Function

    A module gathers components and uses an own store for shared instances dependency injection. Every not provided dependency will be loaded from the application instance store

    example
    
      @Module({
    
      })
      class Test {}
    

    Parameters

    Returns (Anonymous function)

Patch

  • Since 1.7 Property Decorator Function Works basically like the @Endpoint decorator, but only PATCH requests will be mapped to it. this will enable duplicate routes on different method types

    Parameters

    Returns function

      • (target: Object, key: string): void
      • Parameters

        • target: Object
        • key: string

        Returns void

Post

  • Since 1.7 Property Decorator Function Works basically like the @Endpoint decorator, but only POST requests will be mapped to it. this will enable duplicate routes on different method types

    Parameters

    Returns function

      • (target: Object, key: string): void
      • Parameters

        • target: Object
        • key: string

        Returns void

Put

  • Since 1.7 Property Decorator Function Works basically like the @Endpoint decorator, but only PUT requests will be mapped to it. this will enable duplicate routes on different method types

    Parameters

    Returns function

      • (target: Object, key: string): void
      • Parameters

        • target: Object
        • key: string

        Returns void