@@ -12,21 +12,22 @@ import {
12
12
} from "./error" ;
13
13
import { ConflictError } from "./error/ConflictError" ;
14
14
15
+ type Details = string | string [ ] | undefined ;
15
16
export interface APIGatewayResponse extends Omit < APIGatewayProxyResult , "body" > {
16
17
body : unknown | undefined ;
17
18
}
18
19
19
- export function badRequest ( details : string | undefined ) : APIGatewayResponse {
20
+ export function badRequest ( details : Details ) : APIGatewayResponse {
20
21
const error : BadRequestError = new BadRequestError ( details ) ;
21
22
return buildResult < BadRequestError > ( error , constants . HTTP_STATUS_BAD_REQUEST ) ;
22
23
}
23
24
24
- export function forbidden ( details : string | undefined ) : APIGatewayResponse {
25
+ export function forbidden ( details : Details ) : APIGatewayResponse {
25
26
const error : ForbiddenError = new ForbiddenError ( details ) ;
26
27
return buildResult < ForbiddenError > ( error , constants . HTTP_STATUS_FORBIDDEN ) ;
27
28
}
28
29
29
- export function unauthorized ( details : string | undefined ) : APIGatewayResponse {
30
+ export function unauthorized ( details : Details ) : APIGatewayResponse {
30
31
const error : UnauthorizedError = new UnauthorizedError ( details ) ;
31
32
return buildResult < UnauthorizedError > ( error , constants . HTTP_STATUS_UNAUTHORIZED ) ;
32
33
}
@@ -36,22 +37,22 @@ export function internalServerError(): APIGatewayResponse {
36
37
return buildResult < InternalServerError > ( error , constants . HTTP_STATUS_INTERNAL_SERVER_ERROR ) ;
37
38
}
38
39
39
- export function notFound ( details : string | undefined ) : APIGatewayResponse {
40
+ export function notFound ( details : Details ) : APIGatewayResponse {
40
41
const error : NotFoundError = new NotFoundError ( details ) ;
41
42
return buildResult < NotFoundError > ( error , constants . HTTP_STATUS_NOT_FOUND ) ;
42
43
}
43
44
44
- export function requestTimeout ( details : string | undefined ) : APIGatewayResponse {
45
+ export function requestTimeout ( details : Details ) : APIGatewayResponse {
45
46
const error : RequestTimeoutError = new RequestTimeoutError ( details ) ;
46
47
return buildResult < RequestTimeoutError > ( error , constants . HTTP_STATUS_REQUEST_TIMEOUT ) ;
47
48
}
48
49
49
- export function unprocessableEntity ( details : string | undefined ) : APIGatewayResponse {
50
+ export function unprocessableEntity ( details : Details ) : APIGatewayResponse {
50
51
const error : UnprocessableEntityError = new UnprocessableEntityError ( details ) ;
51
52
return buildResult < UnprocessableEntityError > ( error , constants . HTTP_STATUS_UNPROCESSABLE_ENTITY ) ;
52
53
}
53
54
54
- export function conflict ( details : string | undefined ) : APIGatewayResponse {
55
+ export function conflict ( details : Details ) : APIGatewayResponse {
55
56
const error : ConflictError = new ConflictError ( details ) ;
56
57
return buildResult < ConflictError > ( error , constants . HTTP_STATUS_CONFLICT ) ;
57
58
}
0 commit comments