elysia 0.4.10 → 0.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -105,7 +105,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
105
105
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
106
106
  } : Schema['response'] extends Record<string, TSchema | string> ? {
107
107
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
108
- } : ReturnType<Handler>;
108
+ } : {
109
+ '200': ReturnType<Handler>;
110
+ };
109
111
  };
110
112
  };
111
113
  }>>;
@@ -125,7 +127,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
125
127
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
126
128
  } : Schema['response'] extends Record<string, TSchema | string> ? {
127
129
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
128
- } : ReturnType<Handler>;
130
+ } : {
131
+ '200': ReturnType<Handler>;
132
+ };
129
133
  };
130
134
  };
131
135
  }>>;
@@ -145,7 +149,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
145
149
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
146
150
  } : Schema['response'] extends Record<string, TSchema | string> ? {
147
151
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
148
- } : ReturnType<Handler>;
152
+ } : {
153
+ '200': ReturnType<Handler>;
154
+ };
149
155
  };
150
156
  };
151
157
  }>>;
@@ -165,7 +171,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
165
171
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
166
172
  } : Schema['response'] extends Record<string, TSchema | string> ? {
167
173
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
168
- } : ReturnType<Handler>;
174
+ } : {
175
+ '200': ReturnType<Handler>;
176
+ };
169
177
  };
170
178
  };
171
179
  }>>;
@@ -185,7 +193,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
185
193
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
186
194
  } : Schema['response'] extends Record<string, TSchema | string> ? {
187
195
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
188
- } : ReturnType<Handler>;
196
+ } : {
197
+ '200': ReturnType<Handler>;
198
+ };
189
199
  };
190
200
  };
191
201
  }>>;
@@ -205,7 +215,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
205
215
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
206
216
  } : Schema['response'] extends Record<string, TSchema | string> ? {
207
217
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
208
- } : ReturnType<Handler>;
218
+ } : {
219
+ '200': ReturnType<Handler>;
220
+ };
209
221
  };
210
222
  };
211
223
  }>>;
@@ -225,7 +237,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
225
237
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
226
238
  } : Schema['response'] extends Record<string, TSchema | string> ? {
227
239
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
228
- } : ReturnType<Handler>;
240
+ } : {
241
+ '200': ReturnType<Handler>;
242
+ };
229
243
  };
230
244
  };
231
245
  }>>;
@@ -245,7 +259,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
245
259
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
246
260
  } : Schema['response'] extends Record<string, TSchema | string> ? {
247
261
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
248
- } : ReturnType<Handler>;
262
+ } : {
263
+ '200': ReturnType<Handler>;
264
+ };
249
265
  };
250
266
  };
251
267
  }>>;
@@ -265,7 +281,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
265
281
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
266
282
  } : Schema['response'] extends Record<string, TSchema | string> ? {
267
283
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
268
- } : ReturnType<Handler>;
284
+ } : {
285
+ '200': ReturnType<Handler>;
286
+ };
269
287
  };
270
288
  };
271
289
  }>>;
@@ -285,7 +303,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
285
303
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
286
304
  } : Schema['response'] extends Record<string, TSchema | string> ? {
287
305
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
288
- } : ReturnType<Handler>;
306
+ } : {
307
+ '200': ReturnType<Handler>;
308
+ };
289
309
  };
290
310
  };
291
311
  }>>;
@@ -313,7 +333,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
313
333
  '200': UnwrapSchema<Schema['response'], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
314
334
  } : Schema['response'] extends Record<string, TSchema | string> ? {
315
335
  [key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance['meta'][typeof DEFS], ReturnType<Handler>>;
316
- } : ReturnType<Handler>;
336
+ } : {
337
+ '200': ReturnType<Handler>;
338
+ };
317
339
  };
318
340
  };
319
341
  }>>;
package/dist/types.d.ts CHANGED
@@ -25,7 +25,7 @@ export type ElysiaInstance<Instance extends {
25
25
  schema: Instance['schema'];
26
26
  meta: Instance['meta'];
27
27
  };
28
- export type Handler<Route extends OverwritableTypeRoute, Instance extends ElysiaInstance = ElysiaInstance, CatchResponse = unknown> = (context: Context<Route, Instance['store']> & Instance['request']) => IsUnknown<Route['response']> extends false ? Route['response'] extends Record<number, infer Unioned extends TSchema> ? Response | MaybePromise<Unioned> : Response | MaybePromise<Route['response']> : Response | MaybePromise<CatchResponse>;
28
+ export type Handler<Route extends OverwritableTypeRoute, Instance extends ElysiaInstance = ElysiaInstance, CatchResponse = unknown> = (context: Context<Route, Instance['store']> & Instance['request']) => IsUnknown<Route['response']> extends true ? Response | MaybePromise<CatchResponse> : Route['response'] extends TSchema ? Response | MaybePromise<UnwrapSchema<Route['response']>> : Response | MaybePromise<Route['response']>;
29
29
  export type NoReturnHandler<Route extends TypedRoute = TypedRoute, Instance extends ElysiaInstance = ElysiaInstance> = (context: Context<Route, Instance['store']> & Instance['request']) => void | Promise<void>;
30
30
  export type LifeCycleEvent = 'start' | 'request' | 'parse' | 'transform' | 'beforeHandle' | 'afterHandle' | 'error' | 'stop';
31
31
  export type ListenCallback = ((server: Server) => void) | ((server: Server) => Promise<void>);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elysia",
3
3
  "description": "Fast, and friendly Bun web framework",
4
- "version": "0.4.10",
4
+ "version": "0.4.12",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",
@@ -88,7 +88,9 @@
88
88
  "test": "bun test",
89
89
  "dev": "bun run --hot example/http.ts",
90
90
  "build": "rimraf dist && swc src -d dist && tsc --project tsconfig.esm.json",
91
- "release": "npm run build && npm run test && npm publish"
91
+ "prepublishOnly": "npm run build && npm run test",
92
+ "release": "bunx bumpp package.json --commit --push --tag",
93
+ "release:local": "npm run build && npm run test && npm publish"
92
94
  },
93
95
  "dependencies": {
94
96
  "@sinclair/typebox": "0.26.8",
@@ -105,6 +107,7 @@
105
107
  "@types/node": "^18.15.5",
106
108
  "@typescript-eslint/eslint-plugin": "^5.56.0",
107
109
  "@typescript-eslint/parser": "^5.56.0",
110
+ "bumpp": "^9.1.0",
108
111
  "bun-types": "^0.5.8",
109
112
  "eslint": "^8.36.0",
110
113
  "rimraf": "^3.0.2",
package/src/index.ts CHANGED
@@ -851,7 +851,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
851
851
  ReturnType<Handler>
852
852
  >
853
853
  }
854
- : ReturnType<Handler>
854
+ : {
855
+ '200': ReturnType<Handler>
856
+ }
855
857
  }
856
858
  }
857
859
  }
@@ -952,7 +954,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
952
954
  ReturnType<Handler>
953
955
  >
954
956
  }
955
- : ReturnType<Handler>
957
+ : {
958
+ '200': ReturnType<Handler>
959
+ }
956
960
  }
957
961
  }
958
962
  }
@@ -1053,7 +1057,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
1053
1057
  ReturnType<Handler>
1054
1058
  >
1055
1059
  }
1056
- : ReturnType<Handler>
1060
+ : {
1061
+ '200': ReturnType<Handler>
1062
+ }
1057
1063
  }
1058
1064
  }
1059
1065
  }
@@ -1154,7 +1160,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
1154
1160
  ReturnType<Handler>
1155
1161
  >
1156
1162
  }
1157
- : ReturnType<Handler>
1163
+ : {
1164
+ '200': ReturnType<Handler>
1165
+ }
1158
1166
  }
1159
1167
  }
1160
1168
  }
@@ -1255,7 +1263,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
1255
1263
  ReturnType<Handler>
1256
1264
  >
1257
1265
  }
1258
- : ReturnType<Handler>
1266
+ : {
1267
+ '200': ReturnType<Handler>
1268
+ }
1259
1269
  }
1260
1270
  }
1261
1271
  }
@@ -1356,7 +1366,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
1356
1366
  ReturnType<Handler>
1357
1367
  >
1358
1368
  }
1359
- : ReturnType<Handler>
1369
+ : {
1370
+ '200': ReturnType<Handler>
1371
+ }
1360
1372
  }
1361
1373
  }
1362
1374
  }
@@ -1452,7 +1464,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
1452
1464
  ReturnType<Handler>
1453
1465
  >
1454
1466
  }
1455
- : ReturnType<Handler>
1467
+ : {
1468
+ '200': ReturnType<Handler>
1469
+ }
1456
1470
  }
1457
1471
  }
1458
1472
  }
@@ -1553,7 +1567,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
1553
1567
  ReturnType<Handler>
1554
1568
  >
1555
1569
  }
1556
- : ReturnType<Handler>
1570
+ : {
1571
+ '200': ReturnType<Handler>
1572
+ }
1557
1573
  }
1558
1574
  }
1559
1575
  }
@@ -1654,7 +1670,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
1654
1670
  ReturnType<Handler>
1655
1671
  >
1656
1672
  }
1657
- : ReturnType<Handler>
1673
+ : {
1674
+ '200': ReturnType<Handler>
1675
+ }
1658
1676
  }
1659
1677
  }
1660
1678
  }
@@ -1755,7 +1773,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
1755
1773
  ReturnType<Handler>
1756
1774
  >
1757
1775
  }
1758
- : ReturnType<Handler>
1776
+ : {
1777
+ '200': ReturnType<Handler>
1778
+ }
1759
1779
  }
1760
1780
  }
1761
1781
  }
@@ -1967,7 +1987,9 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {
1967
1987
  ReturnType<Handler>
1968
1988
  >
1969
1989
  }
1970
- : ReturnType<Handler>
1990
+ : {
1991
+ '200': ReturnType<Handler>
1992
+ }
1971
1993
  }
1972
1994
  }
1973
1995
  }
package/src/types.ts CHANGED
@@ -47,11 +47,11 @@ export type Handler<
47
47
  CatchResponse = unknown
48
48
  > = (
49
49
  context: Context<Route, Instance['store']> & Instance['request']
50
- ) => IsUnknown<Route['response']> extends false
51
- ? Route['response'] extends Record<number, infer Unioned extends TSchema>
52
- ? Response | MaybePromise<Unioned>
53
- : Response | MaybePromise<Route['response']>
54
- : Response | MaybePromise<CatchResponse>
50
+ ) => IsUnknown<Route['response']> extends true
51
+ ? Response | MaybePromise<CatchResponse>
52
+ : Route['response'] extends TSchema
53
+ ? Response | MaybePromise<UnwrapSchema<Route['response']>>
54
+ : Response | MaybePromise<Route['response']>
55
55
 
56
56
  export type NoReturnHandler<
57
57
  Route extends TypedRoute = TypedRoute,