Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

Below are some examples for typical use cases:.

Export a class

Codeblock
languagetypescript
declare module '@de.pinuts.apirouter/shared/routing.es6' {
    type HandlerFunction = (req?: HttpRequest, res?: HttpResponse) => any;

    export class RouterBuilder {
        /**
         * Adds a route for handling GET requests.
         *
         * @param pathPattern {String} URL pattern; e.g. `/v3/document/:id`
         * @param handler {function(req, res, next)} The handler function to be called.
         * @returns RouterBuilder
         */
        get(pattern: string, handler: HandlerFunction | Array<HandlerFunction>): RouterBuilder;
    }

    /**
     * Creates a (very!) simple reverse proxy to the given upstream URL.
     * Only GET requests are supported by now.
     *
     * @param {string} upstreamUrl
     * @param {Object} [options]
     * @return HandlerFunction
     */
    export function proxy(upstreamUrl: string, options?: Object): HandlerFunction;
}

...

More examples

Codeblock
languagetypescript
declare module '@de.pinuts.customer/shared/config.mjs' {
    const config: {
        env: string,
        oracle: {
            api: Object
        }
    };

    export default config;
}

declare module '@de.pinuts.customer/shared/client.mjs' {
    import HttpClient from '@de.pinuts.http/shared/HttpClient.es6';

    export function client(): HttpClient;
}

declare module '@de.pinuts.customer/shared/oracleQueue.mjs' {
    import SyncQueue from "@de.pinuts.cmsbs.syncqueue/shared/SyncQueue.es6";

    export var oracleQueue: SyncQueue;
    export default oracleQueue;
}

declare module '@de.pinuts.customer/shared/ApplicationStatus.mjs' {
    const ApplicationStatus: {
        IN_PROGRESS: number,
        SUBMITTED_BY_APPLICANT: number,
        REGISTERED_IN_ORACLE: number,
        REGISTERED_IN_ENAIO: number,
        IN_DECISION: number,
    };
    export default ApplicationStatus;
}

declare module '@de.pinuts.customer/shared/faker.es6' {
    const faker = {
        random: {
            number: (options: {min?: number, max?: number} | undefined) => number,

            arrayElement: (arr: Array) => any
        },

        commerce: {
            price: (min: number, max: number, dec: number, symbol: string) => string,
        },

        internet: {
            email: (firstName?: string, lastName?: string, provider?: string) => string,
            userName: (firstName?: string, lastName?: string) => string
        }
    };

    export default faker;
}