vitek-plugin 0.1.0-beta

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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +908 -0
  3. package/dist/adapters/vite/dev-server.d.ts +23 -0
  4. package/dist/adapters/vite/dev-server.d.ts.map +1 -0
  5. package/dist/adapters/vite/dev-server.js +428 -0
  6. package/dist/adapters/vite/logger.d.ts +33 -0
  7. package/dist/adapters/vite/logger.d.ts.map +1 -0
  8. package/dist/adapters/vite/logger.js +112 -0
  9. package/dist/core/context/create-context.d.ts +39 -0
  10. package/dist/core/context/create-context.d.ts.map +1 -0
  11. package/dist/core/context/create-context.js +34 -0
  12. package/dist/core/file-system/scan-api-dir.d.ts +26 -0
  13. package/dist/core/file-system/scan-api-dir.d.ts.map +1 -0
  14. package/dist/core/file-system/scan-api-dir.js +83 -0
  15. package/dist/core/file-system/watch-api-dir.d.ts +18 -0
  16. package/dist/core/file-system/watch-api-dir.d.ts.map +1 -0
  17. package/dist/core/file-system/watch-api-dir.js +40 -0
  18. package/dist/core/middleware/compose.d.ts +12 -0
  19. package/dist/core/middleware/compose.d.ts.map +1 -0
  20. package/dist/core/middleware/compose.js +27 -0
  21. package/dist/core/middleware/get-applicable-middlewares.d.ts +17 -0
  22. package/dist/core/middleware/get-applicable-middlewares.d.ts.map +1 -0
  23. package/dist/core/middleware/get-applicable-middlewares.js +47 -0
  24. package/dist/core/middleware/load-global.d.ts +13 -0
  25. package/dist/core/middleware/load-global.d.ts.map +1 -0
  26. package/dist/core/middleware/load-global.js +37 -0
  27. package/dist/core/normalize/normalize-path.d.ts +25 -0
  28. package/dist/core/normalize/normalize-path.d.ts.map +1 -0
  29. package/dist/core/normalize/normalize-path.js +76 -0
  30. package/dist/core/routing/route-matcher.d.ts +10 -0
  31. package/dist/core/routing/route-matcher.d.ts.map +1 -0
  32. package/dist/core/routing/route-matcher.js +32 -0
  33. package/dist/core/routing/route-parser.d.ts +28 -0
  34. package/dist/core/routing/route-parser.d.ts.map +1 -0
  35. package/dist/core/routing/route-parser.js +52 -0
  36. package/dist/core/routing/route-types.d.ts +43 -0
  37. package/dist/core/routing/route-types.d.ts.map +1 -0
  38. package/dist/core/routing/route-types.js +5 -0
  39. package/dist/core/types/extract-ast.d.ts +18 -0
  40. package/dist/core/types/extract-ast.d.ts.map +1 -0
  41. package/dist/core/types/extract-ast.js +26 -0
  42. package/dist/core/types/generate.d.ts +22 -0
  43. package/dist/core/types/generate.d.ts.map +1 -0
  44. package/dist/core/types/generate.js +576 -0
  45. package/dist/core/types/schema.d.ts +21 -0
  46. package/dist/core/types/schema.d.ts.map +1 -0
  47. package/dist/core/types/schema.js +17 -0
  48. package/dist/core/validation/types.d.ts +27 -0
  49. package/dist/core/validation/types.d.ts.map +1 -0
  50. package/dist/core/validation/types.js +5 -0
  51. package/dist/core/validation/validator.d.ts +22 -0
  52. package/dist/core/validation/validator.d.ts.map +1 -0
  53. package/dist/core/validation/validator.js +131 -0
  54. package/dist/index.d.ts +8 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +4 -0
  57. package/dist/plugin.d.ts +27 -0
  58. package/dist/plugin.d.ts.map +1 -0
  59. package/dist/plugin.js +54 -0
  60. package/dist/shared/constants.d.ts +13 -0
  61. package/dist/shared/constants.d.ts.map +1 -0
  62. package/dist/shared/constants.js +12 -0
  63. package/dist/shared/errors.d.ts +75 -0
  64. package/dist/shared/errors.d.ts.map +1 -0
  65. package/dist/shared/errors.js +118 -0
  66. package/dist/shared/response-helpers.d.ts +61 -0
  67. package/dist/shared/response-helpers.d.ts.map +1 -0
  68. package/dist/shared/response-helpers.js +100 -0
  69. package/dist/shared/utils.d.ts +17 -0
  70. package/dist/shared/utils.d.ts.map +1 -0
  71. package/dist/shared/utils.js +27 -0
  72. package/package.json +48 -0
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Shared utilities
3
+ */
4
+ /**
5
+ * Normalizes a path by removing double slashes and ensuring consistent format
6
+ * Preserves the leading slash if present
7
+ */
8
+ export function normalizePath(path) {
9
+ const normalized = path.replace(/\/+/g, '/');
10
+ // If it ends with / and it's not just the root slash, remove it
11
+ if (normalized !== '/' && normalized.endsWith('/')) {
12
+ return normalized.slice(0, -1);
13
+ }
14
+ return normalized || '/';
15
+ }
16
+ /**
17
+ * Checks if a string is a valid HTTP method
18
+ */
19
+ export function isHttpMethod(str) {
20
+ return ['get', 'post', 'put', 'patch', 'delete', 'head', 'options'].includes(str.toLowerCase());
21
+ }
22
+ /**
23
+ * Capitalizes the first letter of a string
24
+ */
25
+ export function capitalize(str) {
26
+ return str.charAt(0).toUpperCase() + str.slice(1);
27
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "vitek-plugin",
3
+ "version": "0.1.0-beta",
4
+ "description": "Vite plugin for file-based HTTP API generation",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsc --watch",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "vite",
24
+ "plugin",
25
+ "api",
26
+ "file-based",
27
+ "routing"
28
+ ],
29
+ "author": "Victor Bicudo <victor.mbicudo@gmail.com> (https://github.com/martinsbicudo)",
30
+ "license": "MIT",
31
+ "homepage": "https://github.com/martinsbicudo/vitek-plugin#readme",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/martinsbicudo/vitek-plugin.git"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/martinsbicudo/vitek-plugin/issues"
38
+ },
39
+ "peerDependencies": {
40
+ "vite": "^5.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^20.0.0",
44
+ "typescript": "^5.0.0",
45
+ "vite": "^5.0.0"
46
+ }
47
+ }
48
+