@aponiajs/platform-elysia 0.3.22 → 0.4.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.
Files changed (2) hide show
  1. package/dist/index.mjs +21 -2
  2. package/package.json +6 -4
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { AponiaError, Logger, Module, createToken, getConstructorDependencies, getControllerMetadata, getModuleMetadata, getRouteMetadata, provideFactory, provideValue, tokenName } from "@aponiajs/common";
1
+ import { AponiaError, Logger, Module, createToken, getConstructorDependencies, getControllerMetadata, getModuleMetadata, getRouteMetadata, isStandardSchema, provideFactory, provideValue, tokenName } from "@aponiajs/common";
2
2
  import { createContainer } from "@aponiajs/core";
3
3
  import { Elysia } from "elysia";
4
4
  //#region src/controller.ts
@@ -125,12 +125,31 @@ function compileDecoratedController(controller) {
125
125
  controller: controller.name,
126
126
  handler: String(route.propertyKey)
127
127
  });
128
- plugin.route(route.method, joinPaths(metadata.path, route.path), () => Reflect.apply(handler, instance, []));
128
+ plugin.route(route.method, joinPaths(metadata.path, route.path), (context) => Reflect.apply(handler, instance, [context]), toRouteHook(route.schema));
129
129
  }
130
130
  return plugin;
131
131
  }
132
132
  });
133
133
  }
134
+ function toRouteHook(schema) {
135
+ if (!schema) return;
136
+ const hook = {
137
+ ...schema.body ? { body: toElysiaSchema(schema.body) } : {},
138
+ ...schema.query ? { query: toElysiaSchema(schema.query) } : {},
139
+ ...schema.params ? { params: toElysiaSchema(schema.params) } : {},
140
+ ...schema.headers ? { headers: toElysiaSchema(schema.headers) } : {},
141
+ ...schema.response ? { response: toElysiaSchema(schema.response) } : {}
142
+ };
143
+ return Object.keys(hook).length === 0 ? void 0 : hook;
144
+ }
145
+ /**
146
+ * Standard Schema validators pass through unchanged. Platform-native TypeBox
147
+ * validators reach the platform through the neutral `NativeSchema` contract,
148
+ * which cannot describe TypeBox's `Kind` symbol, so they are restored here.
149
+ */
150
+ function toElysiaSchema(validator) {
151
+ return isStandardSchema(validator) ? validator : validator;
152
+ }
134
153
  function joinPaths(controllerPath, routePath) {
135
154
  const segments = [controllerPath, routePath].map((path) => path.trim().replace(/^\/+|\/+$/g, "")).filter(Boolean);
136
155
  return segments.length === 0 ? "/" : `/${segments.join("/")}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aponiajs/platform-elysia",
3
- "version": "0.3.22",
3
+ "version": "0.4.0",
4
4
  "description": "Minimal Elysia application platform for Aponia modules and controllers.",
5
5
  "homepage": "https://github.com/aponiajs/aponiajs#readme",
6
6
  "bugs": {
@@ -33,11 +33,13 @@
33
33
  "prepublishOnly": "bun run build"
34
34
  },
35
35
  "dependencies": {
36
- "@aponiajs/common": "0.3.22",
37
- "@aponiajs/core": "0.3.22"
36
+ "@aponiajs/common": "0.4.0",
37
+ "@aponiajs/core": "0.4.0"
38
38
  },
39
39
  "devDependencies": {
40
- "elysia": "^1.4.29"
40
+ "arktype": "^2.2.3",
41
+ "elysia": "^1.4.29",
42
+ "zod": "^4.4.3"
41
43
  },
42
44
  "peerDependencies": {
43
45
  "elysia": "^1.4.29"