File tree 2 files changed +54
-0
lines changed 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ /// <reference path="statuses.d.ts" />
2
+
3
+ import status = require( 'statuses' ) ;
4
+
5
+ var code : number ;
6
+
7
+ code = status ( 403 ) // => 403
8
+ code = status ( '403' ) // => 403
9
+ code = status ( 'forbidden' ) // => 403
10
+ code = status ( 'Forbidden' ) // => 403
11
+ code = status ( 306 ) // throws, as it's not supported by node.js
12
+
13
+ var codes : Array < number > ;
14
+ codes = status . codes ;
15
+
16
+ var msg : string ;
17
+ msg = status [ 404 ] // => 'Not Found'
18
+
19
+ code = status [ 'not found' ] // => 404
20
+ code = status [ 'Not Found' ] // => 404
21
+
22
+ var isRedirect : boolean ;
23
+ isRedirect = status . redirect [ 200 ] // => undefined
24
+ isRedirect = status . redirect [ 301 ] // => true
25
+
26
+ var isEmpty : boolean ;
27
+ isEmpty = status . empty [ 200 ] // => undefined
28
+ isEmpty = status . empty [ 204 ] // => true
29
+ isEmpty = status . empty [ 304 ] // => true
30
+
31
+ var isRetry : boolean ;
32
+ isRetry = status . retry [ 501 ] // => undefined
33
+ isRetry = status . retry [ 503 ] // => true
Original file line number Diff line number Diff line change
1
+ // Type definitions for http-errors v1.2.1
2
+ // Project: https://github.com/jshttp/statuses
3
+ // Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
4
+ // Definitions: https://github.com/borisyankov/DefinitelyTyped
5
+
6
+ declare module 'statuses' {
7
+ interface Status {
8
+ [ code : number ] : string ;
9
+ [ msg : string ] : any | number ;
10
+
11
+ codes : Array < number > ;
12
+ redirect : { [ code : number ] : boolean } ;
13
+ empty : { [ code : number ] : boolean } ;
14
+ retry : { [ code : number ] : boolean } ;
15
+
16
+ ( code : number | string ) : number ;
17
+ }
18
+
19
+ var status : Status ;
20
+ export = status ;
21
+ }
You can’t perform that action at this time.
0 commit comments