elysia-autoload 0.1.3 → 0.1.4

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
@@ -55,13 +55,13 @@ Guide how `elysia-autoload` match routes
55
55
 
56
56
  ## Options
57
57
 
58
- | Key | Type | Default | Description |
59
- | -------- | ------------------------------------------ | ------------------------------ | ----------------------------------------------------------------------------------- |
60
- | pattern? | string | "\*\/.{ts,tsx,js,jsx,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 |
58
+ | Key | Type | Default | Description |
59
+ | -------- | ------------------------------------------ | ---------------------------------- | ----------------------------------------------------------------------------------- |
60
+ | pattern? | string | "\*\*\/\*.{ts,tsx,js,jsx,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
 
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ async function autoload({ pattern, dir, prefix, schema, types, } = {}) {
57
57
  paths.push(fullPath.replace(directoryPath, ""));
58
58
  }
59
59
  if (types) {
60
- const imports = paths.map((x, index) => `import Route${index} from "${directoryPath + x.replace(".ts", "")}";`);
60
+ const imports = paths.map((x, index) => `import Route${index} from "${directoryPath + x.replace(".ts", "").replace(".tsx", "")}";`);
61
61
  for await (const outputPath of types === true || !types.output
62
62
  ? [TYPES_OUTPUT_DEFAULT]
63
63
  : Array.isArray(types.output)
package/dist/utils.js CHANGED
@@ -14,7 +14,7 @@ exports.getPath = getPath;
14
14
  function transformToUrl(path) {
15
15
  const replacements = [
16
16
  // Clean the url extensions
17
- { regex: /\.(ts|js|mjs|cjs)$/u, replacement: "" },
17
+ { regex: /\.(ts|tsx|js|jsx|mjs|cjs)$/u, replacement: "" },
18
18
  // Handle wild card based routes - users/[...id]/profile.ts -> users/*/profile
19
19
  { regex: /\[\.\.\..*\]/gu, replacement: "*" },
20
20
  // Handle generic square bracket based routes - users/[id]/index.ts -> users/:id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elysia-autoload",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
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",