elysia-autoload 0.1.0 → 0.1.1
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 +14 -13
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -3
- package/package.json +6 -2
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# elysia-autoload
|
2
2
|
|
3
|
-
Plugin for [Elysia](https://elysiajs.com/) which autoload all routes in directory and code-generate types for Eden
|
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)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -55,22 +55,23 @@ Guide how `elysia-autoload` match routes
|
|
55
55
|
|
56
56
|
## Options
|
57
57
|
|
58
|
-
| Key | Type
|
59
|
-
| -------- |
|
60
|
-
| pattern? | string
|
61
|
-
| dir? | string
|
62
|
-
| prefix? | string
|
63
|
-
| types? |
|
64
|
-
| schema? | Function
|
58
|
+
| Key | Type | Default | Description |
|
59
|
+
| -------- | ------------------------------------------ | --------------------------- | ----------------------------------------------------------------------------------- |
|
60
|
+
| pattern? | string | "\*\*_/\*_.{ts,js,mjs,cjs}" | [Glob patterns](<https://en.wikipedia.org/wiki/Glob_(programming)>) |
|
61
|
+
| dir? | string | "./routes" | The folder where routes are located |
|
62
|
+
| prefix? | string | | Prefix for routes |
|
63
|
+
| types? | boolean \| [Types Options](#types-options) | false | Options to configure type code-generation. if boolean - enables/disables generation |
|
64
|
+
| schema? | Function | | Handler for providing routes guard schema |
|
65
65
|
|
66
66
|
### Types Options
|
67
67
|
|
68
|
-
| Key
|
69
|
-
|
|
70
|
-
| output?
|
71
|
-
| typeName?
|
68
|
+
| Key | Type | Default | Description |
|
69
|
+
| ---------- | ------- | ------------------- | --------------------------------------------------------------------------------------- |
|
70
|
+
| output? | string | "./routes-types.ts" | Type code-generation output |
|
71
|
+
| typeName? | string | "Routes" | Name for code-generated global type for [Eden](https://elysiajs.com/eden/overview.html) |
|
72
|
+
| useExport? | boolean | false | Use export instead of global type |
|
72
73
|
|
73
|
-
### Usage of types code-generation for eden
|
74
|
+
### Usage of types code-generation for [Eden](https://elysiajs.com/eden/overview.html)
|
74
75
|
|
75
76
|
```ts
|
76
77
|
// app.ts
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -64,13 +64,13 @@ async function autoload({ pattern, dir, prefix, schema, types, } = {}) {
|
|
64
64
|
`import type { ElysiaWithBaseUrl } from "elysia-autoload";`,
|
65
65
|
imports.join("\n"),
|
66
66
|
"",
|
67
|
-
"declare global {",
|
68
|
-
` type ${types === true || !types.typeName
|
67
|
+
types === true || !types.useExport ? "declare global {" : "",
|
68
|
+
` export type ${types === true || !types.typeName
|
69
69
|
? TYPES_TYPENAME_DEFAULT
|
70
70
|
: types.typeName} = ${paths
|
71
71
|
.map((x, index) => `ElysiaWithBaseUrl<"${(0, utils_1.transformToUrl)(x) || "/"}", ReturnType<typeof Route${index}>>`)
|
72
72
|
.join("\n & ")}`,
|
73
|
-
"}",
|
73
|
+
types === true || !types.useExport ? "}" : "",
|
74
74
|
].join("\n"));
|
75
75
|
}
|
76
76
|
return app;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "elysia-autoload",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.1",
|
4
4
|
"author": "kravetsone",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"description": "Plugin for Elysia which autoload all routes in directory and code-generate types for Eden",
|
@@ -12,7 +12,11 @@
|
|
12
12
|
"autoload",
|
13
13
|
"nextjs",
|
14
14
|
"filerouter",
|
15
|
-
"autoroutes"
|
15
|
+
"autoroutes",
|
16
|
+
"eden",
|
17
|
+
"treaty",
|
18
|
+
"trpc",
|
19
|
+
"codegeneration"
|
16
20
|
],
|
17
21
|
"scripts": {
|
18
22
|
"prepublishOnly": "tsc",
|