arri 0.0.31 → 0.0.33

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.
@@ -35,14 +35,14 @@ require('node:v8');
35
35
  require('consola');
36
36
  require('esbuild');
37
37
  require('prettier');
38
- require('../shared/arri.0d456112.cjs');
38
+ require('../shared/arri.a83bc214.cjs');
39
39
  require('@sinclair/typebox');
40
40
  require('h3');
41
41
  require('@sinclair/typebox/errors');
42
42
  require('@sinclair/typebox/value');
43
43
  require('../index.cjs');
44
44
  require('ofetch');
45
- require('../shared/arri.a8b148d1.cjs');
45
+ require('../shared/arri.aace9c55.cjs');
46
46
  require('child_process');
47
47
  require('listhen');
48
48
 
@@ -33,14 +33,14 @@ import 'node:v8';
33
33
  import 'consola';
34
34
  import 'esbuild';
35
35
  import 'prettier';
36
- import '../shared/arri.6f4fe9d8.mjs';
36
+ import '../shared/arri.76f7a6f9.mjs';
37
37
  import '@sinclair/typebox';
38
38
  import 'h3';
39
39
  import '@sinclair/typebox/errors';
40
40
  import '@sinclair/typebox/value';
41
41
  import '../index.mjs';
42
42
  import 'ofetch';
43
- import '../shared/arri.0f1b603c.mjs';
43
+ import '../shared/arri.984c232f.mjs';
44
44
  import 'child_process';
45
45
  import 'listhen';
46
46
 
package/dist/cli.cjs CHANGED
@@ -25,7 +25,7 @@ const require$$0$3 = require('stream');
25
25
  const consola = require('consola');
26
26
  const esbuild = require('esbuild');
27
27
  const prettier = require('prettier');
28
- const app = require('./shared/arri.0d456112.cjs');
28
+ const app = require('./shared/arri.a83bc214.cjs');
29
29
  const index = require('./index.cjs');
30
30
  require('node:stream');
31
31
  const ofetch = require('ofetch');
@@ -33,7 +33,7 @@ require('@sinclair/typebox');
33
33
  require('h3');
34
34
  require('@sinclair/typebox/errors');
35
35
  require('@sinclair/typebox/value');
36
- const dart = require('./shared/arri.a8b148d1.cjs');
36
+ const dart = require('./shared/arri.aace9c55.cjs');
37
37
  const listhen = require('listhen');
38
38
  require('child_process');
39
39
 
package/dist/cli.mjs CHANGED
@@ -23,7 +23,7 @@ import require$$0$3 from 'stream';
23
23
  import { createConsola } from 'consola';
24
24
  import { build as build$1 } from 'esbuild';
25
25
  import prettier from 'prettier';
26
- import { j as camelCase, r as removeDisallowedChars, o as kebabCase, k as isApplicationDef, D as DEV_DEFINITION_ENDPOINT } from './shared/arri.6f4fe9d8.mjs';
26
+ import { j as camelCase, r as removeDisallowedChars, o as kebabCase, k as isApplicationDef, D as DEV_DEFINITION_ENDPOINT } from './shared/arri.76f7a6f9.mjs';
27
27
  import { defaultConfig } from './index.mjs';
28
28
  import 'node:stream';
29
29
  import { ofetch } from 'ofetch';
@@ -31,7 +31,7 @@ import '@sinclair/typebox';
31
31
  import 'h3';
32
32
  import '@sinclair/typebox/errors';
33
33
  import '@sinclair/typebox/value';
34
- import { a as dartClientGenerator } from './shared/arri.0f1b603c.mjs';
34
+ import { a as dartClientGenerator } from './shared/arri.984c232f.mjs';
35
35
  import { listenAndWatch } from 'listhen';
36
36
  import 'child_process';
37
37
 
package/dist/codegen.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  const require$$0 = require('fs');
4
4
  const prettier = require('prettier');
5
- const app = require('./shared/arri.0d456112.cjs');
6
- const dart = require('./shared/arri.a8b148d1.cjs');
5
+ const app = require('./shared/arri.a83bc214.cjs');
6
+ const dart = require('./shared/arri.aace9c55.cjs');
7
7
  require('@sinclair/typebox');
8
8
  require('h3');
9
9
  require('@sinclair/typebox/errors');
@@ -1,5 +1,5 @@
1
- import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.1f0e8d09.cjs';
2
- export { C as ClientGenerator, a7 as JsonSchemaArray, a3 as JsonSchemaComplexType, Y as JsonSchemaComplexTypeValues, aa as JsonSchemaEnum, a1 as JsonSchemaNullType, X as JsonSchemaNullTypeValues, a5 as JsonSchemaRecord, $ as JsonSchemaScalarType, W as JsonSchemaScalarTypeValues, Z as JsonSchemaType, _ as JsonSchemaTypeValue, a9 as JsonSchemaUint8Array, I as defineClientGeneratorPlugin, O as isApplicationDef, a8 as isJsonSchemaArray, ab as isJsonSchemaEnum, a2 as isJsonSchemaNullType, a4 as isJsonSchemaObject, a6 as isJsonSchemaRecord, a0 as isJsonSchemaScalarType, L as isProcedureDef, N as isServiceDef, K as normalizeWhitespace, V as removeDisallowedChars, U as setNestedObjectProperty, Q as unflattenObject, T as unflattenProcedures } from './shared/arri.1f0e8d09.cjs';
1
+ import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.36bc8896.cjs';
2
+ export { C as ClientGenerator, a7 as JsonSchemaArray, a3 as JsonSchemaComplexType, Y as JsonSchemaComplexTypeValues, aa as JsonSchemaEnum, a1 as JsonSchemaNullType, X as JsonSchemaNullTypeValues, a5 as JsonSchemaRecord, $ as JsonSchemaScalarType, W as JsonSchemaScalarTypeValues, Z as JsonSchemaType, _ as JsonSchemaTypeValue, a9 as JsonSchemaUint8Array, I as defineClientGeneratorPlugin, O as isApplicationDef, a8 as isJsonSchemaArray, ab as isJsonSchemaEnum, a2 as isJsonSchemaNullType, a4 as isJsonSchemaObject, a6 as isJsonSchemaRecord, a0 as isJsonSchemaScalarType, L as isProcedureDef, N as isServiceDef, K as normalizeWhitespace, V as removeDisallowedChars, U as setNestedObjectProperty, Q as unflattenObject, T as unflattenProcedures } from './shared/arri.36bc8896.cjs';
3
3
  import '@sinclair/typebox';
4
4
  import 'h3';
5
5
 
@@ -1,5 +1,5 @@
1
- import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.1f0e8d09.mjs';
2
- export { C as ClientGenerator, a7 as JsonSchemaArray, a3 as JsonSchemaComplexType, Y as JsonSchemaComplexTypeValues, aa as JsonSchemaEnum, a1 as JsonSchemaNullType, X as JsonSchemaNullTypeValues, a5 as JsonSchemaRecord, $ as JsonSchemaScalarType, W as JsonSchemaScalarTypeValues, Z as JsonSchemaType, _ as JsonSchemaTypeValue, a9 as JsonSchemaUint8Array, I as defineClientGeneratorPlugin, O as isApplicationDef, a8 as isJsonSchemaArray, ab as isJsonSchemaEnum, a2 as isJsonSchemaNullType, a4 as isJsonSchemaObject, a6 as isJsonSchemaRecord, a0 as isJsonSchemaScalarType, L as isProcedureDef, N as isServiceDef, K as normalizeWhitespace, V as removeDisallowedChars, U as setNestedObjectProperty, Q as unflattenObject, T as unflattenProcedures } from './shared/arri.1f0e8d09.mjs';
1
+ import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.36bc8896.mjs';
2
+ export { C as ClientGenerator, a7 as JsonSchemaArray, a3 as JsonSchemaComplexType, Y as JsonSchemaComplexTypeValues, aa as JsonSchemaEnum, a1 as JsonSchemaNullType, X as JsonSchemaNullTypeValues, a5 as JsonSchemaRecord, $ as JsonSchemaScalarType, W as JsonSchemaScalarTypeValues, Z as JsonSchemaType, _ as JsonSchemaTypeValue, a9 as JsonSchemaUint8Array, I as defineClientGeneratorPlugin, O as isApplicationDef, a8 as isJsonSchemaArray, ab as isJsonSchemaEnum, a2 as isJsonSchemaNullType, a4 as isJsonSchemaObject, a6 as isJsonSchemaRecord, a0 as isJsonSchemaScalarType, L as isProcedureDef, N as isServiceDef, K as normalizeWhitespace, V as removeDisallowedChars, U as setNestedObjectProperty, Q as unflattenObject, T as unflattenProcedures } from './shared/arri.36bc8896.mjs';
3
3
  import '@sinclair/typebox';
4
4
  import 'h3';
5
5
 
package/dist/codegen.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.1f0e8d09.js';
2
- export { C as ClientGenerator, a7 as JsonSchemaArray, a3 as JsonSchemaComplexType, Y as JsonSchemaComplexTypeValues, aa as JsonSchemaEnum, a1 as JsonSchemaNullType, X as JsonSchemaNullTypeValues, a5 as JsonSchemaRecord, $ as JsonSchemaScalarType, W as JsonSchemaScalarTypeValues, Z as JsonSchemaType, _ as JsonSchemaTypeValue, a9 as JsonSchemaUint8Array, I as defineClientGeneratorPlugin, O as isApplicationDef, a8 as isJsonSchemaArray, ab as isJsonSchemaEnum, a2 as isJsonSchemaNullType, a4 as isJsonSchemaObject, a6 as isJsonSchemaRecord, a0 as isJsonSchemaScalarType, L as isProcedureDef, N as isServiceDef, K as normalizeWhitespace, V as removeDisallowedChars, U as setNestedObjectProperty, Q as unflattenObject, T as unflattenProcedures } from './shared/arri.1f0e8d09.js';
1
+ import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.36bc8896.js';
2
+ export { C as ClientGenerator, a7 as JsonSchemaArray, a3 as JsonSchemaComplexType, Y as JsonSchemaComplexTypeValues, aa as JsonSchemaEnum, a1 as JsonSchemaNullType, X as JsonSchemaNullTypeValues, a5 as JsonSchemaRecord, $ as JsonSchemaScalarType, W as JsonSchemaScalarTypeValues, Z as JsonSchemaType, _ as JsonSchemaTypeValue, a9 as JsonSchemaUint8Array, I as defineClientGeneratorPlugin, O as isApplicationDef, a8 as isJsonSchemaArray, ab as isJsonSchemaEnum, a2 as isJsonSchemaNullType, a4 as isJsonSchemaObject, a6 as isJsonSchemaRecord, a0 as isJsonSchemaScalarType, L as isProcedureDef, N as isServiceDef, K as normalizeWhitespace, V as removeDisallowedChars, U as setNestedObjectProperty, Q as unflattenObject, T as unflattenProcedures } from './shared/arri.36bc8896.js';
3
3
  import '@sinclair/typebox';
4
4
  import 'h3';
5
5
 
package/dist/codegen.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { writeFileSync } from 'fs';
2
2
  import { format } from 'prettier';
3
- import { u as unflattenObject, i as isServiceDef, p as pascalCase, a as isProcedureDef, b as isJsonSchemaScalarType, c as isJsonSchemaNullType, d as isJsonSchemaObject, e as isJsonSchemaRecord, f as isJsonSchemaEnum, g as isJsonSchemaArray, h as unflattenProcedures, j as camelCase } from './shared/arri.6f4fe9d8.mjs';
4
- export { m as JsonSchemaComplexTypeValues, l as JsonSchemaNullTypeValues, J as JsonSchemaScalarTypeValues, k as isApplicationDef, n as normalizeWhitespace, r as removeDisallowedChars, s as setNestedObjectProperty } from './shared/arri.6f4fe9d8.mjs';
5
- import { d as defineClientGeneratorPlugin } from './shared/arri.0f1b603c.mjs';
6
- export { j as classListTransformer, i as classTransformer, c as createDartClient, a as dartClientGenerator, f as dartModelFromJsonSchema, h as dartParsedJsonField, e as dartProcedureFromServiceDefinition, g as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, k as isDartType, l as isDartTypeWithNullables, t as transformers } from './shared/arri.0f1b603c.mjs';
3
+ import { u as unflattenObject, i as isServiceDef, p as pascalCase, a as isProcedureDef, b as isJsonSchemaScalarType, c as isJsonSchemaNullType, d as isJsonSchemaObject, e as isJsonSchemaRecord, f as isJsonSchemaEnum, g as isJsonSchemaArray, h as unflattenProcedures, j as camelCase } from './shared/arri.76f7a6f9.mjs';
4
+ export { m as JsonSchemaComplexTypeValues, l as JsonSchemaNullTypeValues, J as JsonSchemaScalarTypeValues, k as isApplicationDef, n as normalizeWhitespace, r as removeDisallowedChars, s as setNestedObjectProperty } from './shared/arri.76f7a6f9.mjs';
5
+ import { d as defineClientGeneratorPlugin } from './shared/arri.984c232f.mjs';
6
+ export { j as classListTransformer, i as classTransformer, c as createDartClient, a as dartClientGenerator, f as dartModelFromJsonSchema, h as dartParsedJsonField, e as dartProcedureFromServiceDefinition, g as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, k as isDartType, l as isDartTypeWithNullables, t as transformers } from './shared/arri.984c232f.mjs';
7
7
  import '@sinclair/typebox';
8
8
  import 'h3';
9
9
  import '@sinclair/typebox/errors';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const app = require('./shared/arri.0d456112.cjs');
3
+ const app = require('./shared/arri.a83bc214.cjs');
4
4
  require('@sinclair/typebox');
5
5
  require('h3');
6
6
  require('@sinclair/typebox/errors');
@@ -46,6 +46,7 @@ exports.getRpcParamDefinition = app.getRpcParamDefinition;
46
46
  exports.getRpcParamName = app.getRpcParamName;
47
47
  exports.getRpcPath = app.getRpcPath;
48
48
  exports.getRpcResponseName = app.getRpcResponseName;
49
+ exports.handleH3Error = app.handleH3Error;
49
50
  exports.isHttpMethod = app.isHttpMethod;
50
51
  exports.isRpc = app.isRpc;
51
52
  exports.registerRoute = app.registerRoute;
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as ClientGenerator } from './shared/arri.1f0e8d09.cjs';
2
- export { A as Arri, b as ArriOptions, e as ArriProcedure, d as ArriProcedureBase, h as ArriProcedureHandler, j as ArriProcedurePostHandler, s as ArriRoute, w as ArriRouteHandler, z as ArriRoutePostHandler, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, v as ExtractParams, f as HandlerContext, c as HttpMethod, H as HttpMethodValues, M as Middleware, x as RouteHandlerContext, y as RoutePostHandlerContext, R as RpcHandlerContext, g as RpcPostHandlerContext, m as createRpcDefinition, u as defineMiddleware, t as defineRoute, l as defineRpc, p as getRpcParamDefinition, o as getRpcParamName, n as getRpcPath, q as getRpcResponseName, i as isHttpMethod, k as isRpc, B as registerRoute, r as registerRpc } from './shared/arri.1f0e8d09.cjs';
1
+ import { R as RpcHandlerContext, a as RouteHandlerContext, A as ArriOptions, C as ClientGenerator } from './shared/arri.36bc8896.cjs';
2
+ export { c as Arri, f as ArriProcedure, e as ArriProcedureBase, j as ArriProcedureHandler, k as ArriProcedurePostHandler, t as ArriRoute, x as ArriRouteHandler, z as ArriRoutePostHandler, b as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, w as ExtractParams, g as HandlerContext, d as HttpMethod, H as HttpMethodValues, M as Middleware, y as RoutePostHandlerContext, h as RpcPostHandlerContext, n as createRpcDefinition, v as defineMiddleware, u as defineRoute, m as defineRpc, q as getRpcParamDefinition, p as getRpcParamName, o as getRpcPath, r as getRpcResponseName, i as isHttpMethod, l as isRpc, B as registerRoute, s as registerRpc } from './shared/arri.36bc8896.cjs';
3
3
  import * as _sinclair_typebox from '@sinclair/typebox';
4
4
  import { Static } from '@sinclair/typebox';
5
5
  import { ValueError } from '@sinclair/typebox/errors';
6
- import { H3Error } from 'h3';
6
+ import { H3Error, H3Event } from 'h3';
7
7
  import { BuildOptions } from 'esbuild';
8
8
 
9
9
  declare const ErrorResponse: _sinclair_typebox.TObject<{
@@ -18,6 +18,7 @@ declare function defineError(statusCode: StatusCode, input?: Partial<Omit<ErrorR
18
18
  }): H3Error;
19
19
  declare function errorResponseFromValidationErrors(errors: ValueError[], prefixText?: string): H3Error;
20
20
  type StatusCode = number | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
21
+ declare function handleH3Error(err: unknown, context: RpcHandlerContext | RouteHandlerContext<any>, event: H3Event, onError: ArriOptions["onError"]): Promise<void>;
21
22
 
22
23
  interface ArriConfig {
23
24
  port: number;
@@ -37,4 +38,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
37
38
  declare const defaultConfig: Required<ArriConfig>;
38
39
  declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
39
40
 
40
- export { type ArriConfig, ErrorResponse, type ResolvedArriConfig, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors };
41
+ export { type ArriConfig, ArriOptions, ErrorResponse, type ResolvedArriConfig, RouteHandlerContext, RpcHandlerContext, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors, handleH3Error };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as ClientGenerator } from './shared/arri.1f0e8d09.mjs';
2
- export { A as Arri, b as ArriOptions, e as ArriProcedure, d as ArriProcedureBase, h as ArriProcedureHandler, j as ArriProcedurePostHandler, s as ArriRoute, w as ArriRouteHandler, z as ArriRoutePostHandler, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, v as ExtractParams, f as HandlerContext, c as HttpMethod, H as HttpMethodValues, M as Middleware, x as RouteHandlerContext, y as RoutePostHandlerContext, R as RpcHandlerContext, g as RpcPostHandlerContext, m as createRpcDefinition, u as defineMiddleware, t as defineRoute, l as defineRpc, p as getRpcParamDefinition, o as getRpcParamName, n as getRpcPath, q as getRpcResponseName, i as isHttpMethod, k as isRpc, B as registerRoute, r as registerRpc } from './shared/arri.1f0e8d09.mjs';
1
+ import { R as RpcHandlerContext, a as RouteHandlerContext, A as ArriOptions, C as ClientGenerator } from './shared/arri.36bc8896.mjs';
2
+ export { c as Arri, f as ArriProcedure, e as ArriProcedureBase, j as ArriProcedureHandler, k as ArriProcedurePostHandler, t as ArriRoute, x as ArriRouteHandler, z as ArriRoutePostHandler, b as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, w as ExtractParams, g as HandlerContext, d as HttpMethod, H as HttpMethodValues, M as Middleware, y as RoutePostHandlerContext, h as RpcPostHandlerContext, n as createRpcDefinition, v as defineMiddleware, u as defineRoute, m as defineRpc, q as getRpcParamDefinition, p as getRpcParamName, o as getRpcPath, r as getRpcResponseName, i as isHttpMethod, l as isRpc, B as registerRoute, s as registerRpc } from './shared/arri.36bc8896.mjs';
3
3
  import * as _sinclair_typebox from '@sinclair/typebox';
4
4
  import { Static } from '@sinclair/typebox';
5
5
  import { ValueError } from '@sinclair/typebox/errors';
6
- import { H3Error } from 'h3';
6
+ import { H3Error, H3Event } from 'h3';
7
7
  import { BuildOptions } from 'esbuild';
8
8
 
9
9
  declare const ErrorResponse: _sinclair_typebox.TObject<{
@@ -18,6 +18,7 @@ declare function defineError(statusCode: StatusCode, input?: Partial<Omit<ErrorR
18
18
  }): H3Error;
19
19
  declare function errorResponseFromValidationErrors(errors: ValueError[], prefixText?: string): H3Error;
20
20
  type StatusCode = number | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
21
+ declare function handleH3Error(err: unknown, context: RpcHandlerContext | RouteHandlerContext<any>, event: H3Event, onError: ArriOptions["onError"]): Promise<void>;
21
22
 
22
23
  interface ArriConfig {
23
24
  port: number;
@@ -37,4 +38,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
37
38
  declare const defaultConfig: Required<ArriConfig>;
38
39
  declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
39
40
 
40
- export { type ArriConfig, ErrorResponse, type ResolvedArriConfig, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors };
41
+ export { type ArriConfig, ArriOptions, ErrorResponse, type ResolvedArriConfig, RouteHandlerContext, RpcHandlerContext, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors, handleH3Error };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as ClientGenerator } from './shared/arri.1f0e8d09.js';
2
- export { A as Arri, b as ArriOptions, e as ArriProcedure, d as ArriProcedureBase, h as ArriProcedureHandler, j as ArriProcedurePostHandler, s as ArriRoute, w as ArriRouteHandler, z as ArriRoutePostHandler, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, v as ExtractParams, f as HandlerContext, c as HttpMethod, H as HttpMethodValues, M as Middleware, x as RouteHandlerContext, y as RoutePostHandlerContext, R as RpcHandlerContext, g as RpcPostHandlerContext, m as createRpcDefinition, u as defineMiddleware, t as defineRoute, l as defineRpc, p as getRpcParamDefinition, o as getRpcParamName, n as getRpcPath, q as getRpcResponseName, i as isHttpMethod, k as isRpc, B as registerRoute, r as registerRpc } from './shared/arri.1f0e8d09.js';
1
+ import { R as RpcHandlerContext, a as RouteHandlerContext, A as ArriOptions, C as ClientGenerator } from './shared/arri.36bc8896.js';
2
+ export { c as Arri, f as ArriProcedure, e as ArriProcedureBase, j as ArriProcedureHandler, k as ArriProcedurePostHandler, t as ArriRoute, x as ArriRouteHandler, z as ArriRoutePostHandler, b as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, w as ExtractParams, g as HandlerContext, d as HttpMethod, H as HttpMethodValues, M as Middleware, y as RoutePostHandlerContext, h as RpcPostHandlerContext, n as createRpcDefinition, v as defineMiddleware, u as defineRoute, m as defineRpc, q as getRpcParamDefinition, p as getRpcParamName, o as getRpcPath, r as getRpcResponseName, i as isHttpMethod, l as isRpc, B as registerRoute, s as registerRpc } from './shared/arri.36bc8896.js';
3
3
  import * as _sinclair_typebox from '@sinclair/typebox';
4
4
  import { Static } from '@sinclair/typebox';
5
5
  import { ValueError } from '@sinclair/typebox/errors';
6
- import { H3Error } from 'h3';
6
+ import { H3Error, H3Event } from 'h3';
7
7
  import { BuildOptions } from 'esbuild';
8
8
 
9
9
  declare const ErrorResponse: _sinclair_typebox.TObject<{
@@ -18,6 +18,7 @@ declare function defineError(statusCode: StatusCode, input?: Partial<Omit<ErrorR
18
18
  }): H3Error;
19
19
  declare function errorResponseFromValidationErrors(errors: ValueError[], prefixText?: string): H3Error;
20
20
  type StatusCode = number | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
21
+ declare function handleH3Error(err: unknown, context: RpcHandlerContext | RouteHandlerContext<any>, event: H3Event, onError: ArriOptions["onError"]): Promise<void>;
21
22
 
22
23
  interface ArriConfig {
23
24
  port: number;
@@ -37,4 +38,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
37
38
  declare const defaultConfig: Required<ArriConfig>;
38
39
  declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
39
40
 
40
- export { type ArriConfig, ErrorResponse, type ResolvedArriConfig, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors };
41
+ export { type ArriConfig, ArriOptions, ErrorResponse, type ResolvedArriConfig, RouteHandlerContext, RpcHandlerContext, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors, handleH3Error };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { A as Arri, D as DEV_DEFINITION_ENDPOINT, q as DEV_ENDPOINT_ROOT, K as ErrorResponse, H as HttpMethodValues, x as createRpcDefinition, L as defineError, G as defineMiddleware, F as defineRoute, w as defineRpc, M as errorResponseFromValidationErrors, B as getRpcParamDefinition, z as getRpcParamName, y as getRpcPath, C as getRpcResponseName, t as isHttpMethod, v as isRpc, I as registerRoute, E as registerRpc } from './shared/arri.6f4fe9d8.mjs';
1
+ export { A as Arri, D as DEV_DEFINITION_ENDPOINT, q as DEV_ENDPOINT_ROOT, K as ErrorResponse, H as HttpMethodValues, x as createRpcDefinition, L as defineError, G as defineMiddleware, F as defineRoute, w as defineRpc, M as errorResponseFromValidationErrors, B as getRpcParamDefinition, z as getRpcParamName, y as getRpcPath, C as getRpcResponseName, N as handleH3Error, t as isHttpMethod, v as isRpc, I as registerRoute, E as registerRpc } from './shared/arri.76f7a6f9.mjs';
2
2
  import '@sinclair/typebox';
3
3
  import 'h3';
4
4
  import '@sinclair/typebox/errors';
@@ -1,5 +1,5 @@
1
1
  import { TObject, TSchema, Static } from '@sinclair/typebox';
2
- import { H3Event, Router, App, H3Error } from 'h3';
2
+ import { H3Event, Router, H3Error } from 'h3';
3
3
 
4
4
  interface ApplicationDef {
5
5
  arriSchemaVersion: "0.0.1";
@@ -172,7 +172,7 @@ declare class Arri {
172
172
  registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
173
173
  registerRoute<TPath extends string, TMethod extends HttpMethod = HttpMethod, TQuery extends TObject | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any>(route: ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>): void;
174
174
  getAppDefinition(): ApplicationDef;
175
- getH3Instance(): App;
175
+ getH3Instance(): void;
176
176
  }
177
177
  interface ArriOptions {
178
178
  debug?: boolean;
@@ -202,4 +202,4 @@ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
202
202
  type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
203
203
  declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
204
204
 
205
- export { type JsonSchemaScalarType as $, Arri as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, DEV_DEFINITION_ENDPOINT as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, type ArriOptions as b, type HttpMethod as c, type ArriProcedureBase as d, type ArriProcedure as e, type HandlerContext as f, type RpcPostHandlerContext as g, type ArriProcedureHandler as h, isHttpMethod as i, type ArriProcedurePostHandler as j, isRpc as k, defineRpc as l, createRpcDefinition as m, getRpcPath as n, getRpcParamName as o, getRpcParamDefinition as p, getRpcResponseName as q, registerRpc as r, type ArriRoute as s, defineRoute as t, defineMiddleware as u, type ExtractParams as v, type ArriRouteHandler as w, type RouteHandlerContext as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
205
+ export { type JsonSchemaScalarType as $, type ArriOptions as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, type RouteHandlerContext as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, DEV_DEFINITION_ENDPOINT as b, Arri as c, type HttpMethod as d, type ArriProcedureBase as e, type ArriProcedure as f, type HandlerContext as g, type RpcPostHandlerContext as h, isHttpMethod as i, type ArriProcedureHandler as j, type ArriProcedurePostHandler as k, isRpc as l, defineRpc as m, createRpcDefinition as n, getRpcPath as o, getRpcParamName as p, getRpcParamDefinition as q, getRpcResponseName as r, registerRpc as s, type ArriRoute as t, defineRoute as u, defineMiddleware as v, type ExtractParams as w, type ArriRouteHandler as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
@@ -1,5 +1,5 @@
1
1
  import { TObject, TSchema, Static } from '@sinclair/typebox';
2
- import { H3Event, Router, App, H3Error } from 'h3';
2
+ import { H3Event, Router, H3Error } from 'h3';
3
3
 
4
4
  interface ApplicationDef {
5
5
  arriSchemaVersion: "0.0.1";
@@ -172,7 +172,7 @@ declare class Arri {
172
172
  registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
173
173
  registerRoute<TPath extends string, TMethod extends HttpMethod = HttpMethod, TQuery extends TObject | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any>(route: ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>): void;
174
174
  getAppDefinition(): ApplicationDef;
175
- getH3Instance(): App;
175
+ getH3Instance(): void;
176
176
  }
177
177
  interface ArriOptions {
178
178
  debug?: boolean;
@@ -202,4 +202,4 @@ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
202
202
  type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
203
203
  declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
204
204
 
205
- export { type JsonSchemaScalarType as $, Arri as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, DEV_DEFINITION_ENDPOINT as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, type ArriOptions as b, type HttpMethod as c, type ArriProcedureBase as d, type ArriProcedure as e, type HandlerContext as f, type RpcPostHandlerContext as g, type ArriProcedureHandler as h, isHttpMethod as i, type ArriProcedurePostHandler as j, isRpc as k, defineRpc as l, createRpcDefinition as m, getRpcPath as n, getRpcParamName as o, getRpcParamDefinition as p, getRpcResponseName as q, registerRpc as r, type ArriRoute as s, defineRoute as t, defineMiddleware as u, type ExtractParams as v, type ArriRouteHandler as w, type RouteHandlerContext as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
205
+ export { type JsonSchemaScalarType as $, type ArriOptions as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, type RouteHandlerContext as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, DEV_DEFINITION_ENDPOINT as b, Arri as c, type HttpMethod as d, type ArriProcedureBase as e, type ArriProcedure as f, type HandlerContext as g, type RpcPostHandlerContext as h, isHttpMethod as i, type ArriProcedureHandler as j, type ArriProcedurePostHandler as k, isRpc as l, defineRpc as m, createRpcDefinition as n, getRpcPath as o, getRpcParamName as p, getRpcParamDefinition as q, getRpcResponseName as r, registerRpc as s, type ArriRoute as t, defineRoute as u, defineMiddleware as v, type ExtractParams as w, type ArriRouteHandler as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
@@ -1,5 +1,5 @@
1
1
  import { TObject, TSchema, Static } from '@sinclair/typebox';
2
- import { H3Event, Router, App, H3Error } from 'h3';
2
+ import { H3Event, Router, H3Error } from 'h3';
3
3
 
4
4
  interface ApplicationDef {
5
5
  arriSchemaVersion: "0.0.1";
@@ -172,7 +172,7 @@ declare class Arri {
172
172
  registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
173
173
  registerRoute<TPath extends string, TMethod extends HttpMethod = HttpMethod, TQuery extends TObject | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any>(route: ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>): void;
174
174
  getAppDefinition(): ApplicationDef;
175
- getH3Instance(): App;
175
+ getH3Instance(): void;
176
176
  }
177
177
  interface ArriOptions {
178
178
  debug?: boolean;
@@ -202,4 +202,4 @@ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
202
202
  type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
203
203
  declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
204
204
 
205
- export { type JsonSchemaScalarType as $, Arri as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, DEV_DEFINITION_ENDPOINT as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, type ArriOptions as b, type HttpMethod as c, type ArriProcedureBase as d, type ArriProcedure as e, type HandlerContext as f, type RpcPostHandlerContext as g, type ArriProcedureHandler as h, isHttpMethod as i, type ArriProcedurePostHandler as j, isRpc as k, defineRpc as l, createRpcDefinition as m, getRpcPath as n, getRpcParamName as o, getRpcParamDefinition as p, getRpcResponseName as q, registerRpc as r, type ArriRoute as s, defineRoute as t, defineMiddleware as u, type ExtractParams as v, type ArriRouteHandler as w, type RouteHandlerContext as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
205
+ export { type JsonSchemaScalarType as $, type ArriOptions as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, type RouteHandlerContext as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, DEV_DEFINITION_ENDPOINT as b, Arri as c, type HttpMethod as d, type ArriProcedureBase as e, type ArriProcedure as f, type HandlerContext as g, type RpcPostHandlerContext as h, isHttpMethod as i, type ArriProcedureHandler as j, type ArriProcedurePostHandler as k, isRpc as l, defineRpc as m, createRpcDefinition as n, getRpcPath as o, getRpcParamName as p, getRpcParamDefinition as q, getRpcResponseName as r, registerRpc as s, type ArriRoute as t, defineRoute as u, defineMiddleware as v, type ExtractParams as w, type ArriRouteHandler as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
@@ -1,5 +1,5 @@
1
1
  import { Type, TypeGuard } from '@sinclair/typebox';
2
- import { createError, eventHandler, isPreflightRequest, readValidatedBody, getValidatedQuery, setResponseHeader, send, sendError, createRouter, createApp, getQuery, readBody } from 'h3';
2
+ import { createError, isError, setResponseStatus, sendError, eventHandler, isPreflightRequest, readValidatedBody, getValidatedQuery, setResponseHeader, send, createRouter, createApp, getQuery, readBody } from 'h3';
3
3
  import { ValueErrorType } from '@sinclair/typebox/errors';
4
4
  import { Value } from '@sinclair/typebox/value';
5
5
 
@@ -185,6 +185,17 @@ const errorResponseDefaults = {
185
185
  message: "Network Authentication Required"
186
186
  }
187
187
  };
188
+ async function handleH3Error(err, context, event, onError) {
189
+ const error = isError(err) ? err : defineError(500, { data: err, stack: `${err}` });
190
+ setResponseStatus(event, error.statusCode);
191
+ if (onError) {
192
+ await onError(error, context, event);
193
+ }
194
+ if (event.handled) {
195
+ return;
196
+ }
197
+ sendError(event, error);
198
+ }
188
199
 
189
200
  const NUMBER_CHAR_RE = /\d/;
190
201
  const STR_SPLITTERS = ["-", "_", "/", "."];
@@ -618,12 +629,7 @@ function registerRpc(router, path, procedure, middleware, opts) {
618
629
  await procedure.postHandler(context, event);
619
630
  }
620
631
  } catch (err) {
621
- if (opts.onError) {
622
- await opts.onError(err, context, event);
623
- }
624
- if (!event.handled) {
625
- sendError(event, err);
626
- }
632
+ await handleH3Error(err, context, event, opts.onError);
627
633
  }
628
634
  return "";
629
635
  });
@@ -712,12 +718,7 @@ function registerRoute(router, route, middleware, prefix, opts) {
712
718
  await route.postHandler(context, event);
713
719
  }
714
720
  } catch (err) {
715
- if (opts?.onError) {
716
- await opts.onError(err, context, event);
717
- }
718
- if (!event.handled) {
719
- sendError(event, err);
720
- }
721
+ await handleH3Error(err, context, event, opts?.onError);
721
722
  }
722
723
  return "";
723
724
  });
@@ -792,6 +793,7 @@ class Arri {
792
793
  this.h3Router.use(
793
794
  "/**",
794
795
  eventHandler(async (event) => {
796
+ setResponseStatus(event, 404);
795
797
  const error = defineError(404);
796
798
  const query = getQuery(event);
797
799
  const disallowedBodyMethods = ["GET", "HEAD", "OPTION"];
@@ -809,23 +811,19 @@ class Arri {
809
811
  await m(context, event);
810
812
  }
811
813
  }
812
- } catch (_) {
814
+ } catch (err) {
815
+ await handleH3Error(err, context, event, this.onError);
816
+ }
817
+ if (event.handled) {
818
+ return;
813
819
  }
814
820
  if (this.onError) {
815
- await this.onError(
816
- error,
817
- {
818
- type: "route",
819
- params: void 0,
820
- query: void 0,
821
- body: void 0
822
- },
823
- event
824
- );
821
+ await this.onError(error, context, event);
825
822
  }
826
- if (!event.handled) {
827
- sendError(event, error);
823
+ if (event.handled) {
824
+ return;
828
825
  }
826
+ sendError(event, error);
829
827
  })
830
828
  );
831
829
  }
@@ -871,7 +869,6 @@ class Arri {
871
869
  return appDef;
872
870
  }
873
871
  getH3Instance() {
874
- return this.h3App;
875
872
  }
876
873
  }
877
874
  const HttpMethodValues = [
@@ -889,4 +886,4 @@ const isHttpMethod = (input) => {
889
886
  return HttpMethodValues.includes(input);
890
887
  };
891
888
 
892
- export { Arri as A, getRpcParamDefinition as B, getRpcResponseName as C, DEV_DEFINITION_ENDPOINT as D, registerRpc as E, defineRoute as F, defineMiddleware as G, HttpMethodValues as H, registerRoute as I, JsonSchemaScalarTypeValues as J, ErrorResponse as K, defineError as L, errorResponseFromValidationErrors as M, isProcedureDef as a, isJsonSchemaScalarType as b, isJsonSchemaNullType as c, isJsonSchemaObject as d, isJsonSchemaRecord as e, isJsonSchemaEnum as f, isJsonSchemaArray as g, unflattenProcedures as h, isServiceDef as i, camelCase as j, isApplicationDef as k, JsonSchemaNullTypeValues as l, JsonSchemaComplexTypeValues as m, normalizeWhitespace as n, kebabCase as o, pascalCase as p, DEV_ENDPOINT_ROOT as q, removeDisallowedChars as r, setNestedObjectProperty as s, isHttpMethod as t, unflattenObject as u, isRpc as v, defineRpc as w, createRpcDefinition as x, getRpcPath as y, getRpcParamName as z };
889
+ export { Arri as A, getRpcParamDefinition as B, getRpcResponseName as C, DEV_DEFINITION_ENDPOINT as D, registerRpc as E, defineRoute as F, defineMiddleware as G, HttpMethodValues as H, registerRoute as I, JsonSchemaScalarTypeValues as J, ErrorResponse as K, defineError as L, errorResponseFromValidationErrors as M, handleH3Error as N, isProcedureDef as a, isJsonSchemaScalarType as b, isJsonSchemaNullType as c, isJsonSchemaObject as d, isJsonSchemaRecord as e, isJsonSchemaEnum as f, isJsonSchemaArray as g, unflattenProcedures as h, isServiceDef as i, camelCase as j, isApplicationDef as k, JsonSchemaNullTypeValues as l, JsonSchemaComplexTypeValues as m, normalizeWhitespace as n, kebabCase as o, pascalCase as p, DEV_ENDPOINT_ROOT as q, removeDisallowedChars as r, setNestedObjectProperty as s, isHttpMethod as t, unflattenObject as u, isRpc as v, defineRpc as w, createRpcDefinition as x, getRpcPath as y, getRpcParamName as z };
@@ -1,6 +1,6 @@
1
1
  import { execSync } from 'child_process';
2
2
  import { writeFileSync } from 'fs';
3
- import { h as unflattenProcedures, i as isServiceDef, p as pascalCase, j as camelCase, a as isProcedureDef, d as isJsonSchemaObject, f as isJsonSchemaEnum, c as isJsonSchemaNullType, b as isJsonSchemaScalarType, e as isJsonSchemaRecord, g as isJsonSchemaArray } from './arri.6f4fe9d8.mjs';
3
+ import { h as unflattenProcedures, i as isServiceDef, p as pascalCase, j as camelCase, a as isProcedureDef, d as isJsonSchemaObject, f as isJsonSchemaEnum, c as isJsonSchemaNullType, b as isJsonSchemaScalarType, e as isJsonSchemaRecord, g as isJsonSchemaArray } from './arri.76f7a6f9.mjs';
4
4
 
5
5
  function defineClientGeneratorPlugin(plugin) {
6
6
  return plugin;
@@ -187,6 +187,17 @@ const errorResponseDefaults = {
187
187
  message: "Network Authentication Required"
188
188
  }
189
189
  };
190
+ async function handleH3Error(err, context, event, onError) {
191
+ const error = h3.isError(err) ? err : defineError(500, { data: err, stack: `${err}` });
192
+ h3.setResponseStatus(event, error.statusCode);
193
+ if (onError) {
194
+ await onError(error, context, event);
195
+ }
196
+ if (event.handled) {
197
+ return;
198
+ }
199
+ h3.sendError(event, error);
200
+ }
190
201
 
191
202
  const NUMBER_CHAR_RE = /\d/;
192
203
  const STR_SPLITTERS = ["-", "_", "/", "."];
@@ -620,12 +631,7 @@ function registerRpc(router, path, procedure, middleware, opts) {
620
631
  await procedure.postHandler(context, event);
621
632
  }
622
633
  } catch (err) {
623
- if (opts.onError) {
624
- await opts.onError(err, context, event);
625
- }
626
- if (!event.handled) {
627
- h3.sendError(event, err);
628
- }
634
+ await handleH3Error(err, context, event, opts.onError);
629
635
  }
630
636
  return "";
631
637
  });
@@ -714,12 +720,7 @@ function registerRoute(router, route, middleware, prefix, opts) {
714
720
  await route.postHandler(context, event);
715
721
  }
716
722
  } catch (err) {
717
- if (opts?.onError) {
718
- await opts.onError(err, context, event);
719
- }
720
- if (!event.handled) {
721
- h3.sendError(event, err);
722
- }
723
+ await handleH3Error(err, context, event, opts?.onError);
723
724
  }
724
725
  return "";
725
726
  });
@@ -794,6 +795,7 @@ class Arri {
794
795
  this.h3Router.use(
795
796
  "/**",
796
797
  h3.eventHandler(async (event) => {
798
+ h3.setResponseStatus(event, 404);
797
799
  const error = defineError(404);
798
800
  const query = h3.getQuery(event);
799
801
  const disallowedBodyMethods = ["GET", "HEAD", "OPTION"];
@@ -811,23 +813,19 @@ class Arri {
811
813
  await m(context, event);
812
814
  }
813
815
  }
814
- } catch (_) {
816
+ } catch (err) {
817
+ await handleH3Error(err, context, event, this.onError);
818
+ }
819
+ if (event.handled) {
820
+ return;
815
821
  }
816
822
  if (this.onError) {
817
- await this.onError(
818
- error,
819
- {
820
- type: "route",
821
- params: void 0,
822
- query: void 0,
823
- body: void 0
824
- },
825
- event
826
- );
823
+ await this.onError(error, context, event);
827
824
  }
828
- if (!event.handled) {
829
- h3.sendError(event, error);
825
+ if (event.handled) {
826
+ return;
830
827
  }
828
+ h3.sendError(event, error);
831
829
  })
832
830
  );
833
831
  }
@@ -873,7 +871,6 @@ class Arri {
873
871
  return appDef;
874
872
  }
875
873
  getH3Instance() {
876
- return this.h3App;
877
874
  }
878
875
  }
879
876
  const HttpMethodValues = [
@@ -910,6 +907,7 @@ exports.getRpcParamDefinition = getRpcParamDefinition;
910
907
  exports.getRpcParamName = getRpcParamName;
911
908
  exports.getRpcPath = getRpcPath;
912
909
  exports.getRpcResponseName = getRpcResponseName;
910
+ exports.handleH3Error = handleH3Error;
913
911
  exports.isApplicationDef = isApplicationDef;
914
912
  exports.isHttpMethod = isHttpMethod;
915
913
  exports.isJsonSchemaArray = isJsonSchemaArray;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const child_process = require('child_process');
4
4
  const require$$0 = require('fs');
5
- const app = require('./arri.0d456112.cjs');
5
+ const app = require('./arri.a83bc214.cjs');
6
6
 
7
7
  function defineClientGeneratorPlugin(plugin) {
8
8
  return plugin;
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "chokidar": "^3.5.3",
26
26
  "listhen": "^1.4.4"
27
27
  },
28
- "version": "0.0.31",
28
+ "version": "0.0.33",
29
29
  "repository": {
30
30
  "url": "https://github.com/modiimedia/arri"
31
31
  }