Options
All
  • Public
  • Public/Protected
  • All
Menu

service-model

Index

Functions

Contract

  • Contract(name?: string): ClassDecorator
  • Specifies that a class implements a contract.

    Parameters

    • Optional name: string

      The name of the contract.

    Returns ClassDecorator

Debug

  • Debug(): ClassDecorator
  • Specifies that a service should provide error details, such as stack traces, in errors that are returned to the client. This decorator should not be used in production.

    Example

     @Contract("Calculator")
     @Debug()
     export class CalculatorService {
         ...
     }
    

    Returns ClassDecorator

InjectBody

  • InjectBody(): ParameterDecorator
  • Specifies that the body of a REST message should be passed to the decorated parameter of a service operation.

    Example

    In this example the body of the message, a json object containing the task to create, is passed to the task parameter on the createTask service method.

     @Operation()
     @WebPost("/")
     createTask(@InjectBody() task: Task, callback: Callback): void {
         ...
     }
    

    Returns ParameterDecorator

Operation

  • Specifies that a method on a service is an operation on a service contract.

    Parameters

    Returns MethodDecorator

Service

  • Allows configuration of options for a service.

    Parameters

    Returns ClassDecorator

Versioning

  • Specifies that VersioningBehavior should be used for a service contract. If used, the version of the contract must be provided in semver format.

    Parameters

    • options: VersioningOptions

      The options provided to the VersioningBehavior.

      Example

       @Contract("Calculator")
       @Versioning({ version: "1.0.0" })
       export class CalculatorService {
           ...
       }
      

    Returns ClassDecorator

WebDelete

  • WebDelete(template: string): MethodDecorator
  • Specifies that the operation is callable via a HTTP DELETE request. This is a shortcut for WebInvoke with a method of "DELETE".

    Parameters

    • template: string

      The URL template for the operation. For more information, see UrlTemplate.

      Example

       @Operation()
       @WebDelete("/{id}")
       deleteTask(id: number, callback: Callback): void {
           ...
       }
      

    Returns MethodDecorator

WebGet

  • WebGet(template: string): MethodDecorator
  • Specifies that the operation is callable via a HTTP GET request. This is a shortcut for WebInvoke with a method of "GET".

    Parameters

    • template: string

      The URL template for the operation. For more information, see UrlTemplate.

      Example

       @Operation()
       @WebGet("/")
       getTasks(callback: ResultCallback<Tasks[]>): void {
           ...
       }
      

    Returns MethodDecorator

WebHead

  • WebHead(template: string): MethodDecorator
  • Specifies that the operation is callable via a HTTP HEAD request. This is a shortcut for WebInvoke with a method of "HEAD".

    Parameters

    • template: string

      The URL template for the operation. For more information, see UrlTemplate.

       @Operation()
       @WebHead("/{id}")
       taskExists(id: number, callback: ResultCallback<boolean>): void {
           ...
       }
      

    Returns MethodDecorator

WebInvoke

  • Specifies that the operation is callable via a REST api. This is useful for supporting HTTP methods that do not have shortcut decorators. Shortcut decorators are available for GET, POST, PUT DELETE, and HEAD methods.

    Parameters

    • options: WebInvokeOptions

      Describes how the operation should be called.

      Example

       @Operation()
       @WebInvoke({ method: "OPTIONS", template: "/{id}" })
       getOptions(id: number, callback: ResultCallback<AvailableOptions>): void {
           ...
       }
      

    Returns MethodDecorator

WebPost

  • WebPost(template: string): MethodDecorator
  • Specifies that the operation is callable via a HTTP POST request. This is a shortcut for WebInvoke with a method of "POST".

    Parameters

    • template: string

      The URL template for the operation. For more information, see UrlTemplate.

      Example

       @Operation()
       @WebPost("/")
       createTask(@InjectBody() task: Task, callback: ResultCallback<number>): void {
           ...
       }
      

    Returns MethodDecorator

WebPut

  • WebPut(template: string): MethodDecorator
  • Specifies that the operation is callable via a HTTP PUT request. This is a shortcut for WebInvoke with a method of "PUT".

    Parameters

    • template: string

      The URL template for the operation. For more information, see UrlTemplate.

      Example

       @Operation()
       @WebPut("/{id}")
       updateTask(id: number, @InjectBody() task: Task, callback: Callback): void {
           ...
       }
      

    Returns MethodDecorator

Generated using TypeDoc