ApiRouteSchema: CommonSettingSchema & {
    aliases?: {
        [k: string]: ApiSchemaAlias;
    };
    authentication?: boolean | string;
    authorization?: boolean | string;
    autoAliases?: boolean;
    bodyParsers?: bodyParserOptions | boolean;
    busboyConfig?: BusboyConfig<onEventBusboyConfig<MoleculerWebTypes.Alias>>;
    callOptions?: CallingOptions;
    camelCaseNames?: boolean;
    debounceTime?: number;
    logging?: boolean;
    mappingPolicy?: "all" | "restrict";
    mergeParams?: boolean;
    name?: string;
    onAfterCall?: onAfterCall;
    onBeforeCall?: onBeforeCall;
    path: string;
    whitelist?: (string | RegExp)[];
}

Type declaration

  • Optional aliases?: {
        [k: string]: ApiSchemaAlias;
    }

    You can use alias names instead of action names. You can also specify the method. Otherwise it will handle every method types.
    Using named parameters in aliases is possible. Named parameters are defined by prefixing a colon to the parameter name (:name).

  • Optional authentication?: boolean | string

    To enable the support for authentication, you need to do something similar to what is describe in the Authorization paragraph.
    Also in this case you have to:

    1. Set authentication: true in your routes
    2. Define your custom authenticate method in your service
    3. The returned value will be set to the ctx.meta.user property. You can use it in your actions to get the logged in user entity.
      From v0.10.3: You can define custom authentication and authorization methods for every routes. In this case you should set the method name instead of true value.
  • Optional authorization?: boolean | string

    You can implement authorization. Do 2 things to enable it.

    1. Set authorization: true in your routes.
    2. Define the authorize method in service.
      From v0.10.3: You can define custom authentication and authorization methods for every routes. In this case you should set the method name instead of true value.
  • Optional autoAliases?: boolean

    The auto-alias feature allows you to declare your route alias directly in your services.
    The gateway will dynamically build the full routes from service schema. Gateway will regenerate the routes every time a service joins or leaves the network.
    Use whitelist parameter to specify services that the Gateway should track and build the routes.

  • Optional bodyParsers?: bodyParserOptions | boolean

    Parse incoming request bodies, available under the ctx.params property

  • Optional busboyConfig?: BusboyConfig<onEventBusboyConfig<MoleculerWebTypes.Alias>>

    API Gateway has implemented file uploads.
    You can upload files as a multipart form data (thanks to busboy library) or as a raw request body.
    In both cases, the file is transferred to an action as a Stream.
    In multipart form data mode you can upload multiple files, as well.
    Please note: you have to disable other body parsers in order to accept files.

  • Optional callOptions?: CallingOptions

    The route has a callOptions property which is passed to broker.call. So you can set timeout, retries or fallbackResponse options for routes.

  • Optional camelCaseNames?: boolean

    If alias handler not found, api will try to call service by action name
    This option will convert request url to camelCase before call action

    Example

    `/math/sum-all` => `math.sumAll`
    @default: null
  • Optional debounceTime?: number

    Debounce wait time before call to regenerated aliases when got event "$services.changed"

    Default

    500
    
  • Optional logging?: boolean

    Enable/disable logging

    Default

    true
    
  • Optional mappingPolicy?: "all" | "restrict"

    The route has a mappingPolicy property to handle routes without aliases.
    Available options:
    all - enable to request all routes with or without aliases (default)
    restrict - enable to request only the routes with aliases.

  • Optional mergeParams?: boolean

    To disable parameter merging set mergeParams: false in route settings.
    Default is true

  • Optional name?: string

    From v0.10.2
    Support multiple routes with the same path.
    You should give a unique name for the routes if they have same path.

  • Optional onAfterCall?: onAfterCall

    You could manipulate the data in onAfterCall.
    Must always return the new or original data.

  • Optional onBeforeCall?: onBeforeCall

    The route has before & after call hooks. You can use it to set ctx.meta, access req.headers or modify the response data.

  • path: string

    Path prefix to this route

  • Optional whitelist?: (string | RegExp)[]

    If you don’t want to publish all actions, you can filter them with whitelist option.
    Use match strings or regexp in list. To enable all actions, use "**" item.
    "posts.*": Access any actions in 'posts' service
    "users.list": Access call only the 'users.list' action
    /^math.\w+$/: Access any actions in 'math' service