@mpen/routekit 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.d.mts +4 -0
- package/dist/client/react.d.mts +178 -0
- package/dist/client/react.mjs +142 -0
- package/dist/client.d.mts +433 -0
- package/dist/client.mjs +264 -0
- package/dist/content-BuDOmhH_.mjs +102 -0
- package/dist/core-CzUCxvGk.d.mts +140 -0
- package/dist/core-DbmQauwS.mjs +81 -0
- package/dist/handlers.d.mts +72 -0
- package/dist/handlers.mjs +153 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1152 -0
- package/dist/middleware.d.mts +388 -0
- package/dist/middleware.mjs +1222 -0
- package/dist/request-Dn0zc-xm.mjs +1025 -0
- package/dist/response/content.d.mts +79 -0
- package/dist/response/content.mjs +2 -0
- package/dist/response/json-rpc.d.mts +1 -0
- package/dist/response/json-rpc.mjs +1 -0
- package/dist/response/problem/valibot.d.mts +230 -0
- package/dist/response/problem/valibot.mjs +258 -0
- package/dist/response/problem.d.mts +415 -0
- package/dist/response/problem.mjs +183 -0
- package/dist/response/status.d.mts +45 -0
- package/dist/response/status.mjs +2 -0
- package/dist/responses-B379Ep9Y.d.mts +296 -0
- package/dist/responses-BpVrgeYi.mjs +101 -0
- package/dist/router-Cwb7ak0J.d.mts +1819 -0
- package/dist/routes.d.mts +282 -0
- package/dist/routes.mjs +311 -0
- package/dist/status-C-8mw-FB.mjs +59 -0
- package/dist/valibot-D7liFYyB.d.mts +290 -0
- package/dist/valibot-Du97X-TS.mjs +326 -0
- package/package.json +8 -2
- package/src/bin/gen-api-client.test.ts +0 -70
- package/src/bin/gen-api-client.ts +0 -986
- package/src/client/headers.ts +0 -31
- package/src/client/index.ts +0 -8
- package/src/client/promise.ts +0 -11
- package/src/client/react/index.test.tsx +0 -266
- package/src/client/react/index.ts +0 -431
- package/src/client/responses.test.ts +0 -151
- package/src/client/responses.ts +0 -278
- package/src/client/transport.ts +0 -74
- package/src/client/transports/body-codec.ts +0 -61
- package/src/client/transports/fetch.ts +0 -113
- package/src/client/tsconfig.json +0 -9
- package/src/client/types.ts +0 -15
- package/src/client/url.ts +0 -31
- package/src/index.ts +0 -63
- package/src/router/fetch-types.ts +0 -13
- package/src/router/handlers/index.ts +0 -2
- package/src/router/handlers/openapi/index.ts +0 -2
- package/src/router/handlers/openapi/openapi.ts +0 -293
- package/src/router/integration/zod-openapi.test.ts +0 -74
- package/src/router/lib/charset.test.ts +0 -22
- package/src/router/lib/charset.ts +0 -133
- package/src/router/lib/collections.ts +0 -3
- package/src/router/lib/format.test.ts +0 -67
- package/src/router/lib/format.ts +0 -35
- package/src/router/lib/host.ts +0 -4
- package/src/router/lib/json-schema.ts +0 -6
- package/src/router/lib/media-type.test.ts +0 -122
- package/src/router/lib/media-type.ts +0 -289
- package/src/router/lib/pathname.test.ts +0 -18
- package/src/router/lib/pathname.ts +0 -19
- package/src/router/lib/route-names.ts +0 -70
- package/src/router/lib/route-normalize.test.ts +0 -36
- package/src/router/lib/route-normalize.ts +0 -67
- package/src/router/lib/schema-merge.ts +0 -56
- package/src/router/middleware/accept-ctx.test.ts +0 -33
- package/src/router/middleware/accept-ctx.ts +0 -12
- package/src/router/middleware/body-limit.test.ts +0 -112
- package/src/router/middleware/body-limit.ts +0 -121
- package/src/router/middleware/content-type-context.ts +0 -0
- package/src/router/middleware/cors.test.ts +0 -269
- package/src/router/middleware/cors.ts +0 -490
- package/src/router/middleware/csrf.test.ts +0 -106
- package/src/router/middleware/csrf.ts +0 -192
- package/src/router/middleware/define.ts +0 -249
- package/src/router/middleware/index.ts +0 -34
- package/src/router/middleware/jsxhtml-response.ts +0 -0
- package/src/router/middleware/oas-swagger.ts +0 -0
- package/src/router/middleware/rate-limit.test.ts +0 -886
- package/src/router/middleware/rate-limit.ts +0 -920
- package/src/router/middleware/request-id-ctx.test.ts +0 -183
- package/src/router/middleware/request-id-ctx.ts +0 -135
- package/src/router/middleware/request-logger-format.test.ts +0 -16
- package/src/router/middleware/request-logger-format.ts +0 -269
- package/src/router/middleware/request-logger.test.ts +0 -267
- package/src/router/middleware/request-logger.ts +0 -131
- package/src/router/middleware/start-time-ctx.ts +0 -5
- package/src/router/request.ts +0 -611
- package/src/router/response/core.ts +0 -181
- package/src/router/response/directives.ts +0 -233
- package/src/router/response/formats/content/bodyless.ts +0 -54
- package/src/router/response/formats/content/content.ts +0 -79
- package/src/router/response/formats/content/index.ts +0 -2
- package/src/router/response/formats/json-rpc/index.ts +0 -2
- package/src/router/response/formats/problem/badRequest.ts +0 -90
- package/src/router/response/formats/problem/conflict.ts +0 -90
- package/src/router/response/formats/problem/created.ts +0 -40
- package/src/router/response/formats/problem/index.ts +0 -27
- package/src/router/response/formats/problem/notFound.ts +0 -90
- package/src/router/response/formats/problem/permissionDenied.ts +0 -90
- package/src/router/response/formats/problem/problem.test.ts +0 -888
- package/src/router/response/formats/problem/rateLimited.ts +0 -90
- package/src/router/response/formats/problem/responses.ts +0 -219
- package/src/router/response/formats/problem/root-errors.ts +0 -48
- package/src/router/response/formats/problem/sessionExpired.ts +0 -90
- package/src/router/response/formats/problem/types.ts +0 -170
- package/src/router/response/formats/problem/unauthenticated.ts +0 -90
- package/src/router/response/formats/problem/valibot.ts +0 -410
- package/src/router/response/formats/status/index.ts +0 -1
- package/src/router/response/formats/status/responses.ts +0 -59
- package/src/router/response/formats/status/status.test.ts +0 -21
- package/src/router/response/framers.ts +0 -85
- package/src/router/response/index.ts +0 -28
- package/src/router/response/openapi.test.ts +0 -96
- package/src/router/response/openapi.ts +0 -1
- package/src/router/response/serializers.ts +0 -66
- package/src/router/response/stream.ts +0 -35
- package/src/router/router.test.ts +0 -1571
- package/src/router/router.ts +0 -1965
- package/src/router/routes/index.ts +0 -46
- package/src/router/routes/valibot/index.ts +0 -18
- package/src/router/routes/valibot/valibot.ts +0 -1393
- package/src/router/routes/valibot.test.ts +0 -286
- package/src/router/routes/zod/index.ts +0 -18
- package/src/router/routes/zod/zod.ts +0 -1318
- package/src/router/routes/zod.test.ts +0 -280
- package/src/router/server-interface.ts +0 -31
- package/src/router/types.ts +0 -657
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { HttpStatus } from '@mpen/http'
|
|
2
|
-
import type { RoutekitResponse } from '../../core'
|
|
3
|
-
import { problem, type ProblemResponseInit } from './responses'
|
|
4
|
-
import type { ProblemResponse } from './types'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Options accepted by [`conflict`]{@link conflict}.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* conflict({
|
|
12
|
-
* message: 'The resource already exists.',
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @typeParam Code - Machine-readable primary error code.
|
|
17
|
-
*/
|
|
18
|
-
export interface ConflictInit<Code extends string = 'conflict'> extends Omit<
|
|
19
|
-
ProblemResponseInit<Code>,
|
|
20
|
-
'code' | 'status' | 'message'
|
|
21
|
-
> {
|
|
22
|
-
/**
|
|
23
|
-
* Machine-readable error code. Defaults to `'conflict'`.
|
|
24
|
-
*/
|
|
25
|
-
code?: Code
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Human-readable problem message.
|
|
29
|
-
*/
|
|
30
|
-
message?: string
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* HTTP status code for this response. Defaults to `409`.
|
|
34
|
-
*/
|
|
35
|
-
status?: number | HttpStatus
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Create a standard 409 Conflict problem response envelope.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* return conflict('A user with this email address already exists.')
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @param message - Human-readable problem message.
|
|
47
|
-
* @param init - Optional extra problem response options.
|
|
48
|
-
* @returns Routekit logical response with a `'conflict'` [`ProblemResponse`]{@link ProblemResponse}.
|
|
49
|
-
*/
|
|
50
|
-
export function conflict(
|
|
51
|
-
message: string,
|
|
52
|
-
init?: Omit<ConflictInit<'conflict'>, 'message'>,
|
|
53
|
-
): RoutekitResponse<ProblemResponse<'conflict'>>
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Create a standard 409 Conflict problem response envelope.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```ts
|
|
60
|
-
* return conflict({ message: 'State conflict.' })
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @param init - Optional problem response options.
|
|
64
|
-
* @returns Routekit logical response with a [`ProblemResponse`]{@link ProblemResponse}.
|
|
65
|
-
* @typeParam Code - Machine-readable primary error code.
|
|
66
|
-
*/
|
|
67
|
-
export function conflict<const Code extends string = 'conflict'>(
|
|
68
|
-
init?: ConflictInit<Code>,
|
|
69
|
-
): RoutekitResponse<ProblemResponse<Code>>
|
|
70
|
-
|
|
71
|
-
export function conflict<const Code extends string = 'conflict'>(
|
|
72
|
-
messageOrInit?: string | ConflictInit<Code>,
|
|
73
|
-
init?: Omit<ConflictInit<Code>, 'message'>,
|
|
74
|
-
): RoutekitResponse<ProblemResponse<Code>> {
|
|
75
|
-
if (typeof messageOrInit === 'string') {
|
|
76
|
-
return problem({
|
|
77
|
-
...init,
|
|
78
|
-
code: (init?.code ?? 'conflict') as Code,
|
|
79
|
-
message: messageOrInit,
|
|
80
|
-
status: init?.status ?? HttpStatus.CONFLICT,
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return problem({
|
|
85
|
-
...messageOrInit,
|
|
86
|
-
code: (messageOrInit?.code ?? 'conflict') as Code,
|
|
87
|
-
message: messageOrInit?.message ?? 'Conflict',
|
|
88
|
-
status: messageOrInit?.status ?? HttpStatus.CONFLICT,
|
|
89
|
-
})
|
|
90
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { HttpStatus } from '@mpen/http'
|
|
2
|
-
import { response, type RoutekitResponse } from '../../core'
|
|
3
|
-
import type { SuccessResponseInit } from './responses'
|
|
4
|
-
import type { SuccessResponse } from './types'
|
|
5
|
-
|
|
6
|
-
function withDefinedOptional<Value extends object, Key extends string, Field>(
|
|
7
|
-
value: Value,
|
|
8
|
-
key: Key,
|
|
9
|
-
field: Field | undefined,
|
|
10
|
-
): Value | (Value & Record<Key, Field>) {
|
|
11
|
-
if (field === undefined) return value
|
|
12
|
-
return { ...value, [key]: field } as Value & Record<Key, Field>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Create a `201 Created` standard response envelope.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* router.post('/users', () => created({ id: 'user_123' }))
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param data - Successful response payload.
|
|
24
|
-
* @param init - Response headers and optional metadata.
|
|
25
|
-
* @returns Routekit logical response with an [`SuccessResponse`]{@link SuccessResponse} body.
|
|
26
|
-
* @typeParam Data - Successful response payload type.
|
|
27
|
-
* @typeParam Meta - Optional metadata payload type.
|
|
28
|
-
*/
|
|
29
|
-
export function created<const Data, const Meta = unknown>(
|
|
30
|
-
data: Data,
|
|
31
|
-
init: SuccessResponseInit<Meta> = {},
|
|
32
|
-
): RoutekitResponse<SuccessResponse<Data, Meta>, HttpStatus.CREATED> {
|
|
33
|
-
const { meta, ...responseInit } = init
|
|
34
|
-
const body = withDefinedOptional(
|
|
35
|
-
{ success: true, data } as const,
|
|
36
|
-
'meta',
|
|
37
|
-
meta,
|
|
38
|
-
) as SuccessResponse<Data, Meta>
|
|
39
|
-
return response(body, { ...responseInit, status: HttpStatus.CREATED })
|
|
40
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
ok,
|
|
3
|
-
problem,
|
|
4
|
-
VALIDATION_PROBLEM_CODE,
|
|
5
|
-
validationProblem,
|
|
6
|
-
type SuccessResponseInit,
|
|
7
|
-
type ProblemResponseInit,
|
|
8
|
-
type ValidationProblemInit,
|
|
9
|
-
} from './responses'
|
|
10
|
-
export { created } from './created'
|
|
11
|
-
export { notFound, type NotFoundInit } from './notFound'
|
|
12
|
-
export { permissionDenied, type PermissionDeniedInit } from './permissionDenied'
|
|
13
|
-
export { unauthenticated, type UnauthenticatedInit } from './unauthenticated'
|
|
14
|
-
export { sessionExpired, type SessionExpiredInit } from './sessionExpired'
|
|
15
|
-
export { badRequest, type BadRequestInit } from './badRequest'
|
|
16
|
-
export { conflict, type ConflictInit } from './conflict'
|
|
17
|
-
export { rateLimited, type RateLimitedInit } from './rateLimited'
|
|
18
|
-
export { problemRootErrors } from './root-errors'
|
|
19
|
-
|
|
20
|
-
export type {
|
|
21
|
-
SuccessResponse,
|
|
22
|
-
ProblemError,
|
|
23
|
-
ProblemIssue,
|
|
24
|
-
ProblemIssuePathSegment,
|
|
25
|
-
ProblemResponse,
|
|
26
|
-
StandardResponse,
|
|
27
|
-
} from './types'
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { HttpStatus } from '@mpen/http'
|
|
2
|
-
import type { RoutekitResponse } from '../../core'
|
|
3
|
-
import { problem, type ProblemResponseInit } from './responses'
|
|
4
|
-
import type { ProblemResponse } from './types'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Options accepted by [`notFound`]{@link notFound}.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* notFound({
|
|
12
|
-
* message: 'No user exists for the provided id.',
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @typeParam Code - Machine-readable primary error code.
|
|
17
|
-
*/
|
|
18
|
-
export interface NotFoundInit<Code extends string = 'not_found'> extends Omit<
|
|
19
|
-
ProblemResponseInit<Code>,
|
|
20
|
-
'code' | 'status' | 'message'
|
|
21
|
-
> {
|
|
22
|
-
/**
|
|
23
|
-
* Machine-readable error code. Defaults to `'not_found'`.
|
|
24
|
-
*/
|
|
25
|
-
code?: Code
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Human-readable problem message.
|
|
29
|
-
*/
|
|
30
|
-
message?: string
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* HTTP status code for this response. Defaults to `404`.
|
|
34
|
-
*/
|
|
35
|
-
status?: number | HttpStatus
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Create a standard 404 Not Found problem response envelope.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* return notFound('Todo not found.')
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @param message - Human-readable problem message.
|
|
47
|
-
* @param init - Optional extra problem response options.
|
|
48
|
-
* @returns Routekit logical response with a `'not_found'` [`ProblemResponse`]{@link ProblemResponse}.
|
|
49
|
-
*/
|
|
50
|
-
export function notFound(
|
|
51
|
-
message: string,
|
|
52
|
-
init?: Omit<NotFoundInit<'not_found'>, 'message'>,
|
|
53
|
-
): RoutekitResponse<ProblemResponse<'not_found'>>
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Create a standard 404 Not Found problem response envelope.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```ts
|
|
60
|
-
* return notFound({ message: 'Todo not found.' })
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @param init - Optional problem response options.
|
|
64
|
-
* @returns Routekit logical response with a [`ProblemResponse`]{@link ProblemResponse}.
|
|
65
|
-
* @typeParam Code - Machine-readable primary error code.
|
|
66
|
-
*/
|
|
67
|
-
export function notFound<const Code extends string = 'not_found'>(
|
|
68
|
-
init?: NotFoundInit<Code>,
|
|
69
|
-
): RoutekitResponse<ProblemResponse<Code>>
|
|
70
|
-
|
|
71
|
-
export function notFound<const Code extends string = 'not_found'>(
|
|
72
|
-
messageOrInit?: string | NotFoundInit<Code>,
|
|
73
|
-
init?: Omit<NotFoundInit<Code>, 'message'>,
|
|
74
|
-
): RoutekitResponse<ProblemResponse<Code>> {
|
|
75
|
-
if (typeof messageOrInit === 'string') {
|
|
76
|
-
return problem({
|
|
77
|
-
...init,
|
|
78
|
-
code: (init?.code ?? 'not_found') as Code,
|
|
79
|
-
message: messageOrInit,
|
|
80
|
-
status: init?.status ?? HttpStatus.NOT_FOUND,
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return problem({
|
|
85
|
-
...messageOrInit,
|
|
86
|
-
code: (messageOrInit?.code ?? 'not_found') as Code,
|
|
87
|
-
message: messageOrInit?.message ?? 'Not found',
|
|
88
|
-
status: messageOrInit?.status ?? HttpStatus.NOT_FOUND,
|
|
89
|
-
})
|
|
90
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { HttpStatus } from '@mpen/http'
|
|
2
|
-
import type { RoutekitResponse } from '../../core'
|
|
3
|
-
import { problem, type ProblemResponseInit } from './responses'
|
|
4
|
-
import type { ProblemResponse } from './types'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Options accepted by [`permissionDenied`]{@link permissionDenied}.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* permissionDenied({
|
|
12
|
-
* message: 'You do not have permission to perform this action.',
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @typeParam Code - Machine-readable primary error code.
|
|
17
|
-
*/
|
|
18
|
-
export interface PermissionDeniedInit<Code extends string = 'permission_denied'> extends Omit<
|
|
19
|
-
ProblemResponseInit<Code>,
|
|
20
|
-
'code' | 'status' | 'message'
|
|
21
|
-
> {
|
|
22
|
-
/**
|
|
23
|
-
* Machine-readable error code. Defaults to `'permission_denied'`.
|
|
24
|
-
*/
|
|
25
|
-
code?: Code
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Human-readable problem message.
|
|
29
|
-
*/
|
|
30
|
-
message?: string
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* HTTP status code for this response. Defaults to `403`.
|
|
34
|
-
*/
|
|
35
|
-
status?: number | HttpStatus
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Create a standard 403 Permission Denied problem response envelope.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* return permissionDenied('You are not authorized to edit this profile.')
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @param message - Human-readable problem message.
|
|
47
|
-
* @param init - Optional extra problem response options.
|
|
48
|
-
* @returns Routekit logical response with a `'permission_denied'` [`ProblemResponse`]{@link ProblemResponse}.
|
|
49
|
-
*/
|
|
50
|
-
export function permissionDenied(
|
|
51
|
-
message: string,
|
|
52
|
-
init?: Omit<PermissionDeniedInit<'permission_denied'>, 'message'>,
|
|
53
|
-
): RoutekitResponse<ProblemResponse<'permission_denied'>>
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Create a standard 403 Permission Denied problem response envelope.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```ts
|
|
60
|
-
* return permissionDenied({ message: 'Insufficient scope.' })
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @param init - Optional problem response options.
|
|
64
|
-
* @returns Routekit logical response with a [`ProblemResponse`]{@link ProblemResponse}.
|
|
65
|
-
* @typeParam Code - Machine-readable primary error code.
|
|
66
|
-
*/
|
|
67
|
-
export function permissionDenied<const Code extends string = 'permission_denied'>(
|
|
68
|
-
init?: PermissionDeniedInit<Code>,
|
|
69
|
-
): RoutekitResponse<ProblemResponse<Code>>
|
|
70
|
-
|
|
71
|
-
export function permissionDenied<const Code extends string = 'permission_denied'>(
|
|
72
|
-
messageOrInit?: string | PermissionDeniedInit<Code>,
|
|
73
|
-
init?: Omit<PermissionDeniedInit<Code>, 'message'>,
|
|
74
|
-
): RoutekitResponse<ProblemResponse<Code>> {
|
|
75
|
-
if (typeof messageOrInit === 'string') {
|
|
76
|
-
return problem({
|
|
77
|
-
...init,
|
|
78
|
-
code: (init?.code ?? 'permission_denied') as Code,
|
|
79
|
-
message: messageOrInit,
|
|
80
|
-
status: init?.status ?? HttpStatus.FORBIDDEN,
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return problem({
|
|
85
|
-
...messageOrInit,
|
|
86
|
-
code: (messageOrInit?.code ?? 'permission_denied') as Code,
|
|
87
|
-
message: messageOrInit?.message ?? 'Permission denied',
|
|
88
|
-
status: messageOrInit?.status ?? HttpStatus.FORBIDDEN,
|
|
89
|
-
})
|
|
90
|
-
}
|