mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-09-25 10:30:25 +00:00
Merge pull request #10471 from kimamula/fix_express_accepts
fix definitions of express req.accepts functions
This commit is contained in:
+16
-6
@@ -192,9 +192,10 @@ declare module "express-serve-static-core" {
|
||||
* req.accepts('html, json');
|
||||
* // => "json"
|
||||
*/
|
||||
accepts(type: string): string;
|
||||
|
||||
accepts(type: string[]): string;
|
||||
accepts(): string[];
|
||||
accepts(type: string): string | boolean;
|
||||
accepts(type: string[]): string | boolean;
|
||||
accepts(...type: string[]): string | boolean;
|
||||
|
||||
/**
|
||||
* Returns the first accepted charset of the specified character sets,
|
||||
@@ -204,7 +205,10 @@ declare module "express-serve-static-core" {
|
||||
* For more information, or if you have issues or concerns, see accepts.
|
||||
* @param charset
|
||||
*/
|
||||
acceptsCharsets(charset?: string | string[]): string[];
|
||||
acceptsCharsets(): string[];
|
||||
acceptsCharsets(charset: string): string | boolean;
|
||||
acceptsCharsets(charset: string[]): string | boolean;
|
||||
acceptsCharsets(...charset: string[]): string | boolean;
|
||||
|
||||
/**
|
||||
* Returns the first accepted encoding of the specified encodings,
|
||||
@@ -214,7 +218,10 @@ declare module "express-serve-static-core" {
|
||||
* For more information, or if you have issues or concerns, see accepts.
|
||||
* @param encoding
|
||||
*/
|
||||
acceptsEncodings(encoding?: string | string[]): string[];
|
||||
acceptsEncodings(): string[];
|
||||
acceptsEncodings(encoding: string): string | boolean;
|
||||
acceptsEncodings(encoding: string[]): string | boolean;
|
||||
acceptsEncodings(...encoding: string[]): string | boolean;
|
||||
|
||||
/**
|
||||
* Returns the first accepted language of the specified languages,
|
||||
@@ -225,7 +232,10 @@ declare module "express-serve-static-core" {
|
||||
*
|
||||
* @param lang
|
||||
*/
|
||||
acceptsLanguages(lang?: string | string[]): string[];
|
||||
acceptsLanguages(): string[];
|
||||
acceptsLanguages(lang: string): string | boolean;
|
||||
acceptsLanguages(lang: string[]): string | boolean;
|
||||
acceptsLanguages(...lang: string[]): string | boolean;
|
||||
|
||||
/**
|
||||
* Parse Range header field,
|
||||
|
||||
@@ -50,6 +50,26 @@ router.delete(pathRE);
|
||||
router.use((req, res, next) => { next(); })
|
||||
router.route('/users')
|
||||
.get((req, res, next) => {
|
||||
let types: string[] = req.accepts();
|
||||
let type: string | boolean = req.accepts('json');
|
||||
type = req.accepts(['json', 'text']);
|
||||
type = req.accepts('json', 'text');
|
||||
|
||||
let charsets: string[] = req.acceptsCharsets();
|
||||
let charset: string | boolean = req.acceptsCharsets('utf-8');
|
||||
charset = req.acceptsCharsets(['utf-8', 'utf-16']);
|
||||
charset = req.acceptsCharsets('utf-8', 'utf-16');
|
||||
|
||||
let encodings: string[] = req.acceptsEncodings();
|
||||
let encoding: string | boolean = req.acceptsEncodings('gzip');
|
||||
encoding = req.acceptsEncodings(['gzip', 'deflate']);
|
||||
encoding = req.acceptsEncodings('gzip', 'deflate');
|
||||
|
||||
let languages: string[] = req.acceptsLanguages();
|
||||
let language: string | boolean = req.acceptsLanguages('en');
|
||||
language = req.acceptsLanguages(['en', 'ja']);
|
||||
language = req.acceptsLanguages('en', 'ja');
|
||||
|
||||
res.send(req.query['token']);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user