diff --git a/express-brute/express-brute.d.ts b/express-brute/express-brute.d.ts index 7242d44dc..1e672fdfb 100644 --- a/express-brute/express-brute.d.ts +++ b/express-brute/express-brute.d.ts @@ -45,85 +45,101 @@ declare module "express-brute" { } /** - * @summary Middleware. + * @summary Options for {@link ExpressBrute} class. + * @interface + */ + interface ExpressBruteOptions { + freeRetries: number; + proxyDepth: number; + attachResetToRequest: boolean; + refreshTimeoutOnRequest: boolean; + minWait: number; + maxWait: number; + lifetime: number; + failCallback: (req: express.Request, res: express.Response, next: Function, nextValidRequestDate: any) => void; + handleStoreError: any; +} + +/** + * @summary Middleware. + * @class + */ +class ExpressBrute { + /** + * @summary Constructor. + * @constructor + * @param {any} store The store. + */ + constructor(store: any); + + /** + * @summary Generates middleware that will bounce requests with the same key and IP address that happen faster than the current wait time by calling failCallback. + * @param {Object} options The options. + */ + getMiddleware(options: ExpressBruteMiddleware): express.RequestHandler; + + /** + * @summary Uses the current proxy trust settings to get the current IP from a request object. + * @param {Request} request The HTTP request. + * @return {RequestHandler} The Request handler. + */ + getIPFromRequest(request: express.Request): express.RequestHandler; + + /** + * @summary Middleware that will bounce requests that happen faster than the current wait time by calling failCallback. + * @param {Request} request The HTTP request. + * @param {Response} response The HTTP response. + * @param {Function} next The next middleware. + * @return {RequestHandler} The Request handler. + */ + prevent(request: express.Request, response: express.Response, next: Function): express.RequestHandler; + + /** + * @summary Resets the wait time between requests back to its initial value. + * @param {string} ip The IP address. + * @param {string} key The key. response. + * @param {Function} next The next middleware. + * @return {RequestHandler} The Request handler. + */ + reset(ip: string, key: string, next: Function): express.RequestHandler; +} + +module ExpressBrute { + /** + * @summary In-memory store. * @class */ - class ExpressBrute { + export class MemoryStore { /** * @summary Constructor. * @constructor - * @param {any} store The store. - */ - constructor(store: any); - - /** - * @summary Generates middleware that will bounce requests with the same key and IP address that happen faster than the current wait time by calling failCallback. * @param {Object} options The options. */ - getMiddleware(options: ExpressBruteMiddleware): express.RequestHandler; + constructor(options?: MemoryStoreOptions); + /** + * @summary Gets key value. + * @param {string} key The key name. + * @param {Function} callbck The callback. + */ + get(key: string, callback: (error: any, data: Object) => void): void; /** - * @summary Uses the current proxy trust settings to get the current IP from a request object. - * @param {Request} request The HTTP request. - * @return {RequestHandler} The Request handler. + * @summary Sets the key value. + * @param {string} key The name. + * @param {string} value The value. + * @param {number} lifetime The lifetime. + * @param {Function} callback The callback. */ - getIPFromRequest(request: express.Request): express.RequestHandler; + set(key: string, value: any, lifetime: number, callback: (error: any) => void): void; /** - * @summary Middleware that will bounce requests that happen faster than the current wait time by calling failCallback. - * @param {Request} request The HTTP request. - * @param {Response} response The HTTP response. - * @param {Function} next The next middleware. - * @return {RequestHandler} The Request handler. + * @summary Deletes the key. + * @param {string} key The name. + * @param {Function} callback The callback. */ - prevent(request: express.Request, response: express.Response, next: Function): express.RequestHandler; - - /** - * @summary Resets the wait time between requests back to its initial value. - * @param {string} ip The IP address. - * @param {string} key The key. response. - * @param {Function} next The next middleware. - * @return {RequestHandler} The Request handler. - */ - reset(ip: string, key: string, next: Function): express.RequestHandler; + reset(key: string, callback: (error: any) => void): void; } +} - module ExpressBrute { - /** - * @summary In-memory store. - * @class - */ - export class MemoryStore { - /** - * @summary Constructor. - * @constructor - * @param {Object} options The options. - */ - constructor(options?: MemoryStoreOptions); - /** - * @summary Gets key value. - * @param {string} key The key name. - * @param {Function} callbck The callback. - */ - get(key: string, callback: (error: any, data: Object) => void): void; - - /** - * @summary Sets the key value. - * @param {string} key The name. - * @param {string} value The value. - * @param {number} lifetime The lifetime. - * @param {Function} callback The callback. - */ - set(key: string, value: any, lifetime: number, callback: (error: any) => void): void; - - /** - * @summary Deletes the key. - * @param {string} key The name. - * @param {Function} callback The callback. - */ - reset(key: string, callback: (error: any) => void): void; - } - } - - export = ExpressBrute; +export = ExpressBrute; } diff --git a/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor-tests.ts b/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor-tests.ts new file mode 100644 index 000000000..a28aec01f --- /dev/null +++ b/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor-tests.ts @@ -0,0 +1,10 @@ +/// + +import * as i18next from "i18next"; +import sprintf from "i18next-sprintf-postprocessor"; + +function initTest() { + const i18nextOptions = {}; + i18next.use(sprintf).init(i18nextOptions); + i18next.init({ overloadTranslationOptionHandler: sprintf.overloadTranslationOptionHandler }); +} diff --git a/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor.d.ts b/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor.d.ts new file mode 100644 index 000000000..838cd0311 --- /dev/null +++ b/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor.d.ts @@ -0,0 +1,17 @@ +// Type definitions for i18next-sprintf-postProcessor +// Project: https://github.com/i18next/i18next-sprintf-postProcessor +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "i18next-sprintf-postprocessor" { + import i18next = require("i18next"); + + export default interface i18nextSprintfPostProcessor { + process(value: any, key: string, options: Object): void; + overloadTranslationOptionHandler(args: Array): void; + } + //export default function sprintf(): any; +} diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 9256e7a45..4a20978ff 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -8,6 +8,7 @@ /// /// /// +/// interface IResourceStore { [language: string]: IResourceStoreLanguage; @@ -29,7 +30,11 @@ interface I18nTranslateOptions extends I18nextOptions { context?: any; } -interface I18nextOptions { +interface i18nextSprintfPostProcessorStatic { + overloadTranslationOptionHandler: any; +} + +interface I18nextOptions extends i18nextSprintfPostProcessorStatic { lng?: string; // Default value: undefined load?: string; // Default value: 'all' preload?: string[]; // Default value: [] @@ -77,6 +82,8 @@ interface I18nextOptions { // NOTE https://github.com/borisyankov/DefinitelyTyped/pull/5590 replace?: any; + + overloadTranslationOptionHandler: (args: Array) => void; } interface I18nextStatic {