@spikard/node 0.15.6-rc.9 → 0.16.0-rc.3

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.
@@ -0,0 +1,6 @@
1
+ // DO NOT EDIT - auto-generated by alef
2
+ // alef:hash:7584cccc52425023d4ab10991fe2fa280587fa065753d8d2df1f47da0725054b
3
+ "use strict";
4
+ const _native = require("./index.js");
5
+ const _service = require("./service.cjs");
6
+ module.exports = { ..._native, ..._service };
package/index.d.ts CHANGED
@@ -1,5 +1,96 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ /** Spikard application builder. */
4
+ export declare class App {
5
+ /** Create a new application with the default server configuration. */
6
+ static new(): App
7
+ static default(): App
8
+ constructor()
9
+ /**
10
+ * Register a route using the provided builder and handler function.
11
+ *
12
+ * # Errors
13
+ *
14
+ * Returns an error if route construction fails or if the handler registration fails.
15
+ */
16
+ route(builder: RouteBuilder, handler: ((err: Error | null, arg: any) => any)): void
17
+ /**
18
+ * Register a handler via the `get` variant shortcut.
19
+ *
20
+ * Register a GET route at the given path.
21
+ */
22
+ get(path: string, handler: ((err: Error | null, arg: any) => any)): void
23
+ /**
24
+ * Register a handler via the `post` variant shortcut.
25
+ *
26
+ * Register a POST route at the given path.
27
+ */
28
+ post(path: string, handler: ((err: Error | null, arg: any) => any)): void
29
+ /**
30
+ * Register a handler via the `put` variant shortcut.
31
+ *
32
+ * Register a PUT route at the given path.
33
+ */
34
+ put(path: string, handler: ((err: Error | null, arg: any) => any)): void
35
+ /**
36
+ * Register a handler via the `patch` variant shortcut.
37
+ *
38
+ * Register a PATCH route at the given path.
39
+ */
40
+ patch(path: string, handler: ((err: Error | null, arg: any) => any)): void
41
+ /**
42
+ * Register a handler via the `delete` variant shortcut.
43
+ *
44
+ * Register a DELETE route at the given path.
45
+ */
46
+ delete(path: string, handler: ((err: Error | null, arg: any) => any)): void
47
+ /**
48
+ * Register a handler via the `head` variant shortcut.
49
+ *
50
+ * Register a HEAD route at the given path.
51
+ */
52
+ head(path: string, handler: ((err: Error | null, arg: any) => any)): void
53
+ /**
54
+ * Register a handler via the `options` variant shortcut.
55
+ *
56
+ * Register an OPTIONS route at the given path.
57
+ */
58
+ options(path: string, handler: ((err: Error | null, arg: any) => any)): void
59
+ /**
60
+ * Register a handler via the `connect` variant shortcut.
61
+ *
62
+ * Register a CONNECT route at the given path.
63
+ */
64
+ connect(path: string, handler: ((err: Error | null, arg: any) => any)): void
65
+ /**
66
+ * Register a handler via the `trace` variant shortcut.
67
+ *
68
+ * Register a TRACE route at the given path.
69
+ */
70
+ trace(path: string, handler: ((err: Error | null, arg: any) => any)): void
71
+ /**
72
+ * Call the `run` entrypoint on the inner service.
73
+ *
74
+ * Run the HTTP server using the configured routes.
75
+ *
76
+ * # Errors
77
+ *
78
+ * Returns an error if server construction or execution fails.
79
+ */
80
+ nativeRun(): Promise<void>
81
+ /**
82
+ * Call the `into_router` entrypoint on the inner service.
83
+ *
84
+ * Build the underlying Axum router.
85
+ *
86
+ * # Errors
87
+ *
88
+ * Returns an error if server or router construction fails.
89
+ */
90
+ nativeIntoRouter(): void
91
+ }
92
+ export type JsApp = App
93
+
3
94
  /**
4
95
  * Configuration for GraphQL routes
5
96
  *
@@ -49,10 +140,25 @@ export declare class GraphQLRouteConfig {
49
140
  isPlaygroundEnabled(): boolean
50
141
  /** Get the description if set */
51
142
  getDescription(): string | null
143
+ /**
144
+ * Create a new GraphQL route configuration with defaults
145
+ *
146
+ * Default values:
147
+ * - path: "/graphql"
148
+ * - method: "POST"
149
+ * - `enable_playground`: false
150
+ */
151
+ static new(): GraphQLRouteConfig
52
152
  static default(): GraphQLRouteConfig
153
+ constructor()
53
154
  }
54
155
  export type JsGraphQLRouteConfig = GraphQLRouteConfig
55
156
 
157
+ export declare class HandlerResult {
158
+
159
+ }
160
+ export type JsHandlerResult = HandlerResult
161
+
56
162
  export declare class JsGraphQlErrorInfo {
57
163
  statusCode: number
58
164
  isTransient: boolean
@@ -66,6 +172,42 @@ export declare class JsGraphQlErrorInfo {
66
172
  }
67
173
  export type JsGraphQLErrorInfo = JsGraphQlErrorInfo
68
174
 
175
+ export declare class Request {
176
+
177
+ }
178
+ export type JsRequest = Request
179
+
180
+ export declare class RequestData {
181
+
182
+ }
183
+ export type JsRequestData = RequestData
184
+
185
+ /** Builder for defining a route. */
186
+ export declare class RouteBuilder {
187
+ /** Assign an explicit handler name. */
188
+ handlerName(name: string): RouteBuilder
189
+ /** Provide a raw JSON schema for the request body. */
190
+ requestSchemaJson(schema: any): RouteBuilder
191
+ /** Provide a raw JSON schema for the response body. */
192
+ responseSchemaJson(schema: any): RouteBuilder
193
+ /** Provide a raw JSON schema for request parameters. */
194
+ paramsSchemaJson(schema: any): RouteBuilder
195
+ /** Provide multipart file parameter configuration. */
196
+ fileParamsJson(schema: any): RouteBuilder
197
+ /** Attach a CORS configuration for this route. */
198
+ cors(cors: CorsConfig): RouteBuilder
199
+ /** Attach a compression configuration for this route. */
200
+ compression(compression: CompressionConfig): RouteBuilder
201
+ /** Mark the route as synchronous. */
202
+ sync(): RouteBuilder
203
+ /** Declare the dependency keys that must be resolved before this handler runs. */
204
+ handlerDependencies(dependencies: Array<string>): RouteBuilder
205
+ /** Create a new builder for the provided HTTP method and path. */
206
+ static new(method: JsMethod, path: string): RouteBuilder
207
+ constructor(method: JsMethod, path: string)
208
+ }
209
+ export type JsRouteBuilder = RouteBuilder
210
+
69
211
  /**
70
212
  * Core test client for making HTTP requests to a Spikard application.
71
213
  *
@@ -103,6 +245,22 @@ export interface ApiKeyConfig {
103
245
  headerName: string
104
246
  }
105
247
 
248
+ /**
249
+ * Drive `spikard::App::into_router` from JavaScript.
250
+ *
251
+ * Each entry in `registrations` is a `[method_name, metadata, callback]` triple
252
+ * produced by the TypeScript service class.
253
+ */
254
+ export declare function appIntoRouter(registrations: Array<[string, Array<any>, ((err: Error | null, arg: any) => any)]>): Promise<void>
255
+
256
+ /**
257
+ * Drive `spikard::App::run` from JavaScript.
258
+ *
259
+ * Each entry in `registrations` is a `[method_name, metadata, callback]` triple
260
+ * produced by the TypeScript service class.
261
+ */
262
+ export declare function appRun(registrations: Array<[string, Array<any>, ((err: Error | null, arg: any) => any)]>): Promise<void>
263
+
106
264
  /** AsyncAPI HTTP endpoint configuration */
107
265
  export interface AsyncApiConfig {
108
266
  /** Enable AsyncAPI endpoints (default: false) */
@@ -167,9 +325,9 @@ export declare function corsConfigDefault(): CorsConfig
167
325
  export interface FullSchemaConfig {
168
326
  /** Enable introspection queries */
169
327
  introspectionEnabled?: boolean
170
- /** Maximum query complexity (None = unlimited) */
328
+ /** Maximum query complexity (undefined = unlimited) */
171
329
  complexityLimit?: number
172
- /** Maximum query depth (None = unlimited) */
330
+ /** Maximum query depth (undefined = unlimited) */
173
331
  depthLimit?: number
174
332
  }
175
333
 
@@ -238,7 +396,7 @@ export interface GrpcConfig {
238
396
  maxMessageSize?: number
239
397
  /** Enable gzip compression for gRPC messages */
240
398
  enableCompression?: boolean
241
- /** Timeout for gRPC requests in seconds (None = no timeout) */
399
+ /** Timeout for gRPC requests in seconds (undefined = no timeout) */
242
400
  requestTimeout?: number
243
401
  /**
244
402
  * Maximum number of concurrent streams per connection (HTTP/2 advisory)
@@ -268,7 +426,7 @@ export interface GrpcConfig {
268
426
  * Total byte cap across an entire streaming response.
269
427
  *
270
428
  * When `Some(n)`, the streaming adapter aborts the stream with
271
- * `tonic::Status::resource_exhausted` once the cumulative encoded message
429
+ * `tonic.Status.resource_exhausted` once the cumulative encoded message
272
430
  * bytes exceed `n`. The stream yields the error item and then terminates.
273
431
  *
274
432
  * Per-message cap remains `max_message_size`. This limit applies to
@@ -350,6 +508,7 @@ export declare const enum Method {
350
508
  Delete = 'Delete',
351
509
  Head = 'Head',
352
510
  Options = 'Options',
511
+ Connect = 'Connect',
353
512
  Trace = 'Trace'
354
513
  }
355
514
 
@@ -502,9 +661,9 @@ export declare function problemDetailsWithInstance(cfg: ProblemDetails, instance
502
661
  export interface QueryMutationConfig {
503
662
  /** Enable introspection queries */
504
663
  introspectionEnabled?: boolean
505
- /** Maximum query complexity (None = unlimited) */
664
+ /** Maximum query complexity (undefined = unlimited) */
506
665
  complexityLimit?: number
507
- /** Maximum query depth (None = unlimited) */
666
+ /** Maximum query depth (undefined = unlimited) */
508
667
  depthLimit?: number
509
668
  }
510
669
 
@@ -514,9 +673,9 @@ export declare function queryMutationConfigDefault(): QueryMutationConfig
514
673
  export interface QueryOnlyConfig {
515
674
  /** Enable introspection queries */
516
675
  introspectionEnabled?: boolean
517
- /** Maximum query complexity (None = unlimited) */
676
+ /** Maximum query complexity (undefined = unlimited) */
518
677
  complexityLimit?: number
519
- /** Maximum query depth (None = unlimited) */
678
+ /** Maximum query depth (undefined = unlimited) */
520
679
  depthLimit?: number
521
680
  }
522
681
 
@@ -565,9 +724,9 @@ export interface ResponseSnapshot {
565
724
  export interface SchemaConfig {
566
725
  /** Enable introspection queries */
567
726
  introspectionEnabled?: boolean
568
- /** Maximum query complexity (None = unlimited) */
727
+ /** Maximum query complexity (undefined = unlimited) */
569
728
  complexityLimit?: number
570
- /** Maximum query depth (None = unlimited) */
729
+ /** Maximum query depth (undefined = unlimited) */
571
730
  depthLimit?: number
572
731
  }
573
732
 
@@ -625,9 +784,9 @@ export interface ServerConfig {
625
784
  workers?: number
626
785
  /** Enable request ID generation and propagation */
627
786
  enableRequestId?: boolean
628
- /** Maximum request body size in bytes (None = unlimited, not recommended) */
787
+ /** Maximum request body size in bytes (undefined = unlimited, not recommended) */
629
788
  maxBodySize?: number
630
- /** Request timeout in seconds (None = no timeout) */
789
+ /** Request timeout in seconds (undefined = no timeout) */
631
790
  requestTimeout?: number
632
791
  /** Enable compression middleware */
633
792
  compression?: CompressionConfig
@@ -644,7 +803,7 @@ export interface ServerConfig {
644
803
  /** Graceful shutdown timeout (seconds) */
645
804
  shutdownTimeout?: number
646
805
  /** AsyncAPI HTTP endpoint configuration */
647
- asyncapi?: AsyncApiConfig
806
+ asyncapi?: JsAsyncApiConfig
648
807
  /** OpenAPI documentation configuration */
649
808
  openapi?: OpenApiConfig
650
809
  /** JSON-RPC configuration */
package/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('@spikard/node-android-arm64')
79
79
  const bindingPackageVersion = require('@spikard/node-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('@spikard/node-android-arm-eabi')
95
95
  const bindingPackageVersion = require('@spikard/node-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('@spikard/node-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('@spikard/node-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('@spikard/node-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('@spikard/node-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('@spikard/node-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('@spikard/node-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('@spikard/node-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('@spikard/node-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('@spikard/node-darwin-universal')
184
184
  const bindingPackageVersion = require('@spikard/node-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('@spikard/node-darwin-x64')
200
200
  const bindingPackageVersion = require('@spikard/node-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('@spikard/node-darwin-arm64')
216
216
  const bindingPackageVersion = require('@spikard/node-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@spikard/node-freebsd-x64')
236
236
  const bindingPackageVersion = require('@spikard/node-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('@spikard/node-freebsd-arm64')
252
252
  const bindingPackageVersion = require('@spikard/node-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('@spikard/node-linux-x64-musl')
273
273
  const bindingPackageVersion = require('@spikard/node-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('@spikard/node-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('@spikard/node-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('@spikard/node-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('@spikard/node-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('@spikard/node-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('@spikard/node-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('@spikard/node-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('@spikard/node-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('@spikard/node-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('@spikard/node-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('@spikard/node-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('@spikard/node-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('@spikard/node-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('@spikard/node-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('@spikard/node-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('@spikard/node-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('@spikard/node-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('@spikard/node-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('@spikard/node-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('@spikard/node-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('@spikard/node-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('@spikard/node-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@spikard/node-openharmony-arm64')
478
478
  const bindingPackageVersion = require('@spikard/node-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@spikard/node-openharmony-x64')
494
494
  const bindingPackageVersion = require('@spikard/node-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('@spikard/node-openharmony-arm')
510
510
  const bindingPackageVersion = require('@spikard/node-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.15.6-rc.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.15.6-rc.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.16.0-rc.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.16.0-rc.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -576,12 +576,24 @@ if (!nativeBinding) {
576
576
  }
577
577
 
578
578
  module.exports = nativeBinding
579
+ module.exports.App = nativeBinding.App
580
+ module.exports.JsApp = nativeBinding.JsApp
579
581
  module.exports.GraphQLRouteConfig = nativeBinding.GraphQLRouteConfig
580
582
  module.exports.JsGraphQLRouteConfig = nativeBinding.JsGraphQLRouteConfig
583
+ module.exports.HandlerResult = nativeBinding.HandlerResult
584
+ module.exports.JsHandlerResult = nativeBinding.JsHandlerResult
581
585
  module.exports.JsGraphQlErrorInfo = nativeBinding.JsGraphQlErrorInfo
582
586
  module.exports.JsGraphQLErrorInfo = nativeBinding.JsGraphQLErrorInfo
587
+ module.exports.Request = nativeBinding.Request
588
+ module.exports.JsRequest = nativeBinding.JsRequest
589
+ module.exports.RequestData = nativeBinding.RequestData
590
+ module.exports.JsRequestData = nativeBinding.JsRequestData
591
+ module.exports.RouteBuilder = nativeBinding.RouteBuilder
592
+ module.exports.JsRouteBuilder = nativeBinding.JsRouteBuilder
583
593
  module.exports.TestClient = nativeBinding.TestClient
584
594
  module.exports.JsTestClient = nativeBinding.JsTestClient
595
+ module.exports.appIntoRouter = nativeBinding.appIntoRouter
596
+ module.exports.appRun = nativeBinding.appRun
585
597
  module.exports.backgroundJobMetadataDefault = nativeBinding.backgroundJobMetadataDefault
586
598
  module.exports.backgroundTaskConfigDefault = nativeBinding.backgroundTaskConfigDefault
587
599
  module.exports.compressionConfigDefault = nativeBinding.compressionConfigDefault
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spikard/node",
3
- "version": "0.15.6-rc.9",
3
+ "version": "0.16.0-rc.3",
4
4
  "description": "Rust-centric multi-language HTTP framework with polyglot bindings",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -9,38 +9,39 @@
9
9
  },
10
10
  "files": [
11
11
  "index.js",
12
+ "index-wrapper.cjs",
12
13
  "index.d.ts",
14
+ "service.cjs",
13
15
  "*.node"
14
16
  ],
15
- "main": "index.js",
17
+ "main": "index-wrapper.cjs",
16
18
  "types": "index.d.ts",
17
19
  "exports": {
18
20
  ".": {
19
21
  "types": "./index.d.ts",
20
- "require": "./index.js",
21
- "default": "./index.js"
22
+ "require": "./index-wrapper.cjs",
23
+ "default": "./index-wrapper.cjs"
22
24
  }
23
25
  },
24
26
  "publishConfig": {
25
27
  "access": "public"
26
28
  },
27
29
  "scripts": {
28
- "build": "napi build --platform --release",
29
- "artifacts": "napi artifacts",
30
- "prepublishOnly": "napi prepublish -t npm --skip-optional-publish"
30
+ "build": "npx --yes -p @napi-rs/cli@^3.6.2 napi build --platform --release",
31
+ "artifacts": "npx --yes -p @napi-rs/cli@^3.6.2 napi artifacts",
32
+ "prepublishOnly": "npx --yes -p @napi-rs/cli@^3.6.2 napi prepublish -t npm --skip-optional-publish"
31
33
  },
32
34
  "devDependencies": {
33
35
  "@napi-rs/cli": "^3.6.2"
34
36
  },
35
37
  "optionalDependencies": {
36
- "@spikard/node-darwin-arm64": "0.15.6-rc.9",
37
- "@spikard/node-darwin-x64": "0.15.6-rc.9",
38
- "@spikard/node-linux-arm64-gnu": "0.15.6-rc.9",
39
- "@spikard/node-linux-arm64-musl": "0.15.6-rc.9",
40
- "@spikard/node-linux-x64-gnu": "0.15.6-rc.9",
41
- "@spikard/node-linux-x64-musl": "0.15.6-rc.9",
42
- "@spikard/node-win32-arm64-msvc": "0.15.6-rc.9",
43
- "@spikard/node-win32-x64-msvc": "0.15.6-rc.9"
38
+ "@spikard/node-darwin-arm64": "0.16.0-rc.3",
39
+ "@spikard/node-linux-arm64-gnu": "0.16.0-rc.3",
40
+ "@spikard/node-linux-arm64-musl": "0.16.0-rc.3",
41
+ "@spikard/node-linux-x64-gnu": "0.16.0-rc.3",
42
+ "@spikard/node-linux-x64-musl": "0.16.0-rc.3",
43
+ "@spikard/node-win32-arm64-msvc": "0.16.0-rc.3",
44
+ "@spikard/node-win32-x64-msvc": "0.16.0-rc.3"
44
45
  },
45
46
  "napi": {
46
47
  "binaryName": "spikard-node",
@@ -50,7 +51,6 @@
50
51
  "aarch64-unknown-linux-gnu",
51
52
  "x86_64-unknown-linux-musl",
52
53
  "aarch64-unknown-linux-musl",
53
- "x86_64-apple-darwin",
54
54
  "aarch64-apple-darwin",
55
55
  "x86_64-pc-windows-msvc",
56
56
  "aarch64-pc-windows-msvc"
package/service.cjs ADDED
@@ -0,0 +1,202 @@
1
+ // Auto-generated service API class
2
+
3
+ const { ServerConfig } = require("./index");
4
+ const { App: NativeApp, Method, RouteBuilder } = require("./index");
5
+ const { appIntoRouter, appRun } = require("./index");
6
+ /**
7
+ * Spikard application builder.
8
+ */
9
+ class App {
10
+ _app;
11
+ _config;
12
+
13
+ /**
14
+ * Create a new App instance.
15
+ */
16
+ static new() {
17
+ return new App();
18
+ }
19
+ /**
20
+ * Create a new application with the default server configuration.
21
+ */
22
+ constructor() {
23
+ this._app = new NativeApp();
24
+ }
25
+ /**
26
+ * Set the server configuration.
27
+ */
28
+ config(config) {
29
+ this._config = config;
30
+ this._app.config(JSON.stringify(config));
31
+
32
+ return this;
33
+ }
34
+ /**
35
+ * Register a route using the provided builder and handler function.
36
+ *
37
+ * # Errors
38
+ *
39
+ * Returns an error if route construction fails or if the handler registration fails.
40
+ */
41
+ route(builder) {
42
+ return (fn) => {
43
+ this._app.route(builder, fn);
44
+ return fn;
45
+ };
46
+ }
47
+ /**
48
+ * Register a route callback directly.
49
+ */
50
+ registerRoute(builder, handler) {
51
+ this._app.route(builder, handler);
52
+ return this;
53
+ }
54
+ /**
55
+ * Register a GET route at the given path.
56
+ */
57
+ get(path, handler) {
58
+ const builder = RouteBuilder.new(Method.Get, path);
59
+ if (handler !== undefined) {
60
+ this._app.get(path, handler);
61
+ return this;
62
+ }
63
+ return (fn) => {
64
+ this._app.get(path, fn);
65
+ return fn;
66
+ };
67
+ }
68
+ /**
69
+ * Register a POST route at the given path.
70
+ */
71
+ post(path, handler) {
72
+ const builder = RouteBuilder.new(Method.Post, path);
73
+ if (handler !== undefined) {
74
+ this._app.post(path, handler);
75
+ return this;
76
+ }
77
+ return (fn) => {
78
+ this._app.post(path, fn);
79
+ return fn;
80
+ };
81
+ }
82
+ /**
83
+ * Register a PUT route at the given path.
84
+ */
85
+ put(path, handler) {
86
+ const builder = RouteBuilder.new(Method.Put, path);
87
+ if (handler !== undefined) {
88
+ this._app.put(path, handler);
89
+ return this;
90
+ }
91
+ return (fn) => {
92
+ this._app.put(path, fn);
93
+ return fn;
94
+ };
95
+ }
96
+ /**
97
+ * Register a PATCH route at the given path.
98
+ */
99
+ patch(path, handler) {
100
+ const builder = RouteBuilder.new(Method.Patch, path);
101
+ if (handler !== undefined) {
102
+ this._app.patch(path, handler);
103
+ return this;
104
+ }
105
+ return (fn) => {
106
+ this._app.patch(path, fn);
107
+ return fn;
108
+ };
109
+ }
110
+ /**
111
+ * Register a DELETE route at the given path.
112
+ */
113
+ delete(path, handler) {
114
+ const builder = RouteBuilder.new(Method.Delete, path);
115
+ if (handler !== undefined) {
116
+ this._app.delete(path, handler);
117
+ return this;
118
+ }
119
+ return (fn) => {
120
+ this._app.delete(path, fn);
121
+ return fn;
122
+ };
123
+ }
124
+ /**
125
+ * Register a HEAD route at the given path.
126
+ */
127
+ head(path, handler) {
128
+ const builder = RouteBuilder.new(Method.Head, path);
129
+ if (handler !== undefined) {
130
+ this._app.head(path, handler);
131
+ return this;
132
+ }
133
+ return (fn) => {
134
+ this._app.head(path, fn);
135
+ return fn;
136
+ };
137
+ }
138
+ /**
139
+ * Register an OPTIONS route at the given path.
140
+ */
141
+ options(path, handler) {
142
+ const builder = RouteBuilder.new(Method.Options, path);
143
+ if (handler !== undefined) {
144
+ this._app.options(path, handler);
145
+ return this;
146
+ }
147
+ return (fn) => {
148
+ this._app.options(path, fn);
149
+ return fn;
150
+ };
151
+ }
152
+ /**
153
+ * Register a CONNECT route at the given path.
154
+ */
155
+ connect(path, handler) {
156
+ const builder = RouteBuilder.new(Method.Connect, path);
157
+ if (handler !== undefined) {
158
+ this._app.connect(path, handler);
159
+ return this;
160
+ }
161
+ return (fn) => {
162
+ this._app.connect(path, fn);
163
+ return fn;
164
+ };
165
+ }
166
+ /**
167
+ * Register a TRACE route at the given path.
168
+ */
169
+ trace(path, handler) {
170
+ const builder = RouteBuilder.new(Method.Trace, path);
171
+ if (handler !== undefined) {
172
+ this._app.trace(path, handler);
173
+ return this;
174
+ }
175
+ return (fn) => {
176
+ this._app.trace(path, fn);
177
+ return fn;
178
+ };
179
+ }
180
+ /**
181
+ * Run the HTTP server using the configured routes.
182
+ *
183
+ * # Errors
184
+ *
185
+ * Returns an error if server construction or execution fails.
186
+ */
187
+ async run() {
188
+ return await this._app.run();
189
+ }
190
+ /**
191
+ * Build the underlying Axum router.
192
+ *
193
+ * # Errors
194
+ *
195
+ * Returns an error if server or router construction fails.
196
+ */
197
+ into_router() {
198
+ return this._app.intoRouter();
199
+ }
200
+ }
201
+
202
+ module.exports = { App };
Binary file