elysia-autoload 1.2.1 → 1.3.0

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Plugin for [Elysia](https://elysiajs.com/) which autoload all routes in directory and code-generate types for [Eden](https://elysiajs.com/eden/overview.html) with [`Bun.build`](#bun-build-usage) support!
4
4
 
5
- **Currently, Eden types generation is broken!!**
5
+ **Currently, Eden types generation is broken!!** Feels free to send PR
6
6
 
7
7
  ## Installation
8
8
 
@@ -65,6 +65,9 @@ Guide how `elysia-autoload` match routes
65
65
  └──index.ts
66
66
  ├── frontend
67
67
  └──index.tsx // usage of tsx extension
68
+ ├── events
69
+ └──(post).ts // post and get will not be in the link
70
+ └──(get).ts
68
71
  └── users.ts
69
72
  └── package.json
70
73
  ```
@@ -76,6 +79,8 @@ Guide how `elysia-autoload` match routes
76
79
  - /routes/likes/[...].ts → /likes/\*
77
80
  - /routes/domains/@[...]/index.ts → /domains/@\*
78
81
  - /routes/frontend/index.tsx → /frontend
82
+ - /routes/events/(post).ts → /events
83
+ - /routes/events/(get).ts → /events
79
84
 
80
85
  ## Options
81
86
 
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ type FlattenIndexRoutes<T> = T extends object ? {
16
16
  [K in keyof T as K extends "index" ? T[K] extends RouteEndType ? never : K : K]: FlattenIndexRoutes<T[K]>;
17
17
  } & (T extends {
18
18
  index: infer I;
19
- } ? I extends RouteEndType ? FlattenIndexRoutes<I> : {} : {}) : T;
19
+ } ? I extends RouteEndType ? FlattenIndexRoutes<I> : T : T) : T;
20
20
  type ElysiaWithBaseUrl<BaseUrl extends string, ElysiaType extends Elysia<any, any, any, any, any, any, any, any>> = ElysiaType extends Elysia<infer BasePath, infer Scoped, infer Singleton, infer Definitions, infer Metadata, infer Routes, infer Ephemeral, infer Volatile> ? Elysia<BasePath, Scoped, Singleton, Definitions, Metadata, FlattenIndexRoutes<PathToObject<BaseUrl, Routes>>, Ephemeral, Volatile> : never;
21
21
  type SoftString<T extends string> = T | (string & {});
22
22
 
package/dist/index.js CHANGED
@@ -22,6 +22,10 @@ function transformToUrl(path2) {
22
22
  regex: /\[(.*?)\]/gu,
23
23
  replacement: (_, match) => `:${match}`
24
24
  },
25
+ {
26
+ regex: /\/?\((.*)\)/,
27
+ replacement: ""
28
+ },
25
29
  // Handle the case when multiple parameters are present in one file
26
30
  // users / [id] - [name].ts to users /: id -:name and users / [id] - [name] / [age].ts to users /: id -: name /: age
27
31
  { regex: /\]-\[/gu, replacement: "-:" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elysia-autoload",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "author": "kravetsone",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",