redoc/lib/utils/helpers.ts

17 lines
368 B
TypeScript
Raw Normal View History

2015-11-23 23:27:55 +03:00
'use strict';
export function statusCodeType(statusCode) {
2015-12-12 19:30:13 +03:00
if (statusCode < 100 || statusCode > 599) {
throw new Error('invalid HTTP code');
2015-12-12 19:30:13 +03:00
}
2015-11-23 23:27:55 +03:00
let res = 'success';
if (statusCode >= 300 && statusCode < 400) {
res = 'redirect';
2015-11-23 23:56:44 +03:00
} else if (statusCode >= 400) {
2015-11-23 23:27:55 +03:00
res = 'error';
2015-12-12 19:30:13 +03:00
} else if (statusCode < 200) {
2015-11-23 23:27:55 +03:00
res = 'info';
}
return res;
}