elysia 2.0.0-exp.58 → 2.0.0-exp.59

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.
@@ -2,6 +2,6 @@ import { AnyElysia } from "../../base.js";
2
2
  import { ElysiaAdapterOptions } from "../types.js";
3
3
  //#region src/adapter/bun/index.d.ts
4
4
  declare function collectStaticRoutes(app: AnyElysia): readonly [Record<string, Record<string, Response>>, readonly []] | undefined;
5
- declare const BunAdapter: ElysiaAdapterOptions;
5
+ declare const BunAdapter: ElysiaAdapterOptions<void>;
6
6
  //#endregion
7
7
  export { BunAdapter, collectStaticRoutes };
@@ -1,6 +1,6 @@
1
1
  import { ElysiaAdapterOptions } from "./types.js";
2
2
 
3
3
  //#region src/adapter/constants.d.ts
4
- declare const defaultAdapter: ElysiaAdapterOptions;
4
+ declare const defaultAdapter: ElysiaAdapterOptions<void>;
5
5
  //#endregion
6
6
  export { defaultAdapter };
@@ -1,7 +1,8 @@
1
+ import { AnyElysia } from "../base.js";
1
2
  import { ElysiaAdapterOptions } from "./types.js";
2
3
 
3
4
  //#region src/adapter/index.d.ts
4
- declare const createAdapter: (adapter: ElysiaAdapterOptions) => ElysiaAdapterOptions;
5
+ declare const createAdapter: <App extends AnyElysia | void = void>(adapter: ElysiaAdapterOptions<App>) => ElysiaAdapterOptions<App>;
5
6
  type ElysiaAdapter = ReturnType<typeof createAdapter>;
6
7
  //#endregion
7
8
  export { ElysiaAdapter, type ElysiaAdapterOptions, createAdapter };
@@ -9,7 +9,7 @@ import { AnyElysia } from "../base.js";
9
9
  *
10
10
  * @since 2.0.0
11
11
  */
12
- interface ElysiaAdapterOptions {
12
+ interface ElysiaAdapterOptions<App extends AnyElysia | void = void> {
13
13
  /**
14
14
  * Name of the adapter, preferably runtime
15
15
  */
@@ -49,6 +49,7 @@ interface ElysiaAdapterOptions {
49
49
  */
50
50
  compact?(response: unknown, ...params: unknown[]): unknown;
51
51
  };
52
+ setup?(app: AnyElysia): App;
52
53
  }
53
54
  //#endregion
54
55
  export { ElysiaAdapterOptions };
@@ -1,5 +1,5 @@
1
1
  import { ElysiaAdapterOptions } from "../types.js";
2
2
  //#region src/adapter/web-standard/index.d.ts
3
- declare const WebStandardAdapter: ElysiaAdapterOptions;
3
+ declare const WebStandardAdapter: ElysiaAdapterOptions<void>;
4
4
  //#endregion
5
5
  export { WebStandardAdapter };
package/dist/base.js CHANGED
@@ -124,9 +124,10 @@ var Elysia = class Elysia {
124
124
  this["~scopeChildren"] = void 0;
125
125
  this["~programId"] = require_compile_aot.createProgramId();
126
126
  if (config) {
127
- const { prefix, name, seed } = config;
127
+ const { prefix, name, seed, adapter } = config;
128
128
  this["~Prefix"] = prefix ? prefix.charCodeAt(0) === 47 ? prefix : `/${prefix}` : void 0;
129
129
  if (name) this.#hash = require_utils.fnv1a(seed ? `${name}_${typeof seed === "object" ? JSON.stringify(seed, require_utils.serializeMacroSeed) : seed}` : name);
130
+ if (adapter?.setup) this.#useFn(adapter.setup);
130
131
  } else this["~Prefix"] = void 0;
131
132
  }
132
133
  get routes() {
@@ -1434,7 +1435,6 @@ var Elysia = class Elysia {
1434
1435
  const routePath = path[i];
1435
1436
  const routeFlags = flags[i];
1436
1437
  if ((routeFlags & require_route_table.RouteFlag.WS) !== 0) {
1437
- if (!wsCap) throw new Error(`[Elysia] WebSocket route ${routeMethod} ${routePath} defined, but no WS capability is available. Ensure that .use(websocket()) is applied.`);
1438
1438
  const ws = wsCap.provider.buildWSRoute(require_route_table.routeRow(table, i), this);
1439
1439
  const handler = ws[0];
1440
1440
  const options = ws[1];
package/dist/base.mjs CHANGED
@@ -121,9 +121,10 @@ var Elysia = class Elysia {
121
121
  this["~scopeChildren"] = void 0;
122
122
  this["~programId"] = createProgramId();
123
123
  if (config) {
124
- const { prefix, name, seed } = config;
124
+ const { prefix, name, seed, adapter } = config;
125
125
  this["~Prefix"] = prefix ? prefix.charCodeAt(0) === 47 ? prefix : `/${prefix}` : void 0;
126
126
  if (name) this.#hash = fnv1a(seed ? `${name}_${typeof seed === "object" ? JSON.stringify(seed, serializeMacroSeed) : seed}` : name);
127
+ if (adapter?.setup) this.#useFn(adapter.setup);
127
128
  } else this["~Prefix"] = void 0;
128
129
  }
129
130
  get routes() {
@@ -1431,7 +1432,6 @@ var Elysia = class Elysia {
1431
1432
  const routePath = path[i];
1432
1433
  const routeFlags = flags[i];
1433
1434
  if ((routeFlags & RouteFlag.WS) !== 0) {
1434
- if (!wsCap) throw new Error(`[Elysia] WebSocket route ${routeMethod} ${routePath} defined, but no WS capability is available. Ensure that .use(websocket()) is applied.`);
1435
1435
  const ws = wsCap.provider.buildWSRoute(routeRow(table, i), this);
1436
1436
  const handler = ws[0];
1437
1437
  const options = ws[1];
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "2.0.0-exp.58";
3
+ var version = "2.0.0-exp.59";
4
4
 
5
5
  //#endregion
6
6
  Object.defineProperty(exports, 'version', {
package/dist/package.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "2.0.0-exp.58";
2
+ var version = "2.0.0-exp.59";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -17,7 +17,7 @@ declare const ELYSIA_TYPES: {
17
17
  readonly NoValidate: 15;
18
18
  };
19
19
  type ELYSIA_TYPES = typeof ELYSIA_TYPES;
20
- declare const primitiveElysiaTypes: Set<1 | 2 | 6 | 3 | 10 | 11 | 13 | 14>;
20
+ declare const primitiveElysiaTypes: Set<1 | 2 | 3 | 6 | 10 | 11 | 13 | 14>;
21
21
  declare const noEnumerable: {
22
22
  readonly enumerable: false;
23
23
  };
package/dist/types.d.ts CHANGED
@@ -13,7 +13,7 @@ import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from
13
13
  import { OpenAPIV3 } from "openapi-types";
14
14
 
15
15
  //#region src/types.d.ts
16
- interface ElysiaConfig<in out Prefix extends string | undefined, in out Scope extends EventScope> {
16
+ interface ElysiaConfig<in out Prefix extends string | undefined, in out Scope extends EventScope, in out Adapter extends ElysiaAdapter = ElysiaAdapter> {
17
17
  /**
18
18
  * Define event scope for the instance
19
19
  *
@@ -21,10 +21,10 @@ interface ElysiaConfig<in out Prefix extends string | undefined, in out Scope ex
21
21
  */
22
22
  as?: Scope;
23
23
  /**
24
- * @default BunAdapter
25
- * @since 1.1.11
24
+ * @default BunAdapter v2
25
+ * @since 2.0.0
26
26
  */
27
- adapter?: ElysiaAdapter;
27
+ adapter?: Adapter;
28
28
  /**
29
29
  * Path prefix of the instance
30
30
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elysia",
3
3
  "description": "Ergonomic Framework for Human",
4
- "version": "2.0.0-exp.58",
4
+ "version": "2.0.0-exp.59",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",