Skip to content

Commit

Permalink
Adds typings
Browse files Browse the repository at this point in the history
  • Loading branch information
tinganho committed Sep 15, 2016
1 parent 7c174f7 commit b114b29
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .editorconfig
Expand Up @@ -6,4 +6,4 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
indent_size = 4
52 changes: 52 additions & 0 deletions index.d.ts
@@ -0,0 +1,52 @@

import * as e from '@types/express';

declare module 'express-request-language' {
interface Cookie {

/**
* Cookie name.
*/
name: string;

/**
* Cookie option passed in `res.cookie(name, value, [options])`.
*/
options?: e.CookieOptions;

/**
* URL to change preferred language.
*/
url?: string;
}

interface Options {

/**
* Define your supported languages.
*/
languages: string[];

/**
* Query name used for changing language.
*/
queryName?: string;

/**
* Cookie options.
*/
cookie?: Cookie;

/**
* A localization import function. One of the supported languages will be passed as argument.
* And the result will be set to `req.localization`. Very handy to be used with L10ns https://l10ns.org.
*/
localizations?: (lang: string) => any;
}

/**
* Middleware for language matching.
*/
function requestLanguage(options: Options): any;
export = requestLanguage;
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -24,6 +24,7 @@
},
"homepage": "https://github.com/tinganho/express-request-language",
"dependencies": {
"@types/express": "^4.0.32",
"accept-language": "^3.0.4",
"bcp47": "^1.1.2"
},
Expand Down

0 comments on commit b114b29

Please sign in to comment.