@aponiajs/platform-elysia 0.3.16 → 0.3.18
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 +26 -4
- package/dist/index.d.mts +9 -4
- package/dist/index.mjs +10 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -20,12 +20,12 @@ The first Elysia platform slice for Aponia:
|
|
|
20
20
|
- `handle`, `listen`, and `close` application methods.
|
|
21
21
|
|
|
22
22
|
This package intentionally does not yet implement request scopes, lifecycle
|
|
23
|
-
enhancers, schema aggregation, or the complete native-plugin
|
|
23
|
+
enhancers, schema aggregation, or the complete module-level native-plugin
|
|
24
24
|
contract from the roadmap.
|
|
25
25
|
|
|
26
|
-
The decorator API is the default application authoring surface.
|
|
27
|
-
`defineElysiaController`
|
|
28
|
-
|
|
26
|
+
The decorator API is the default application authoring surface.
|
|
27
|
+
`defineElysiaController` remains available as a low-level escape hatch for
|
|
28
|
+
controller factories.
|
|
29
29
|
|
|
30
30
|
See `docs/logging.md` for logger configuration, JSON output, level filtering,
|
|
31
31
|
and custom logger integration.
|
|
@@ -41,5 +41,27 @@ const application = await AponiaFactory.create(AppModule);
|
|
|
41
41
|
await application.listen(3000);
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
## Native Elysia plugins
|
|
45
|
+
|
|
46
|
+
Use existing Elysia plugins without an Aponia adapter:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
bun add @elysiajs/cors
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { cors } from "@elysiajs/cors";
|
|
54
|
+
|
|
55
|
+
const application = await AponiaFactory.create(AppModule, {
|
|
56
|
+
configureNative: (elysia) => elysia.use(cors()),
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`configureNative` receives the real Elysia application before Aponia mounts its
|
|
61
|
+
controllers. Use Elysia's own `.use()` API for instance, functional, array, and
|
|
62
|
+
lazy plugins; no adapter or route copying is involved. Return the same
|
|
63
|
+
application so Elysia's plugin types remain available from
|
|
64
|
+
`application.getNativeApplication()`.
|
|
65
|
+
|
|
44
66
|
[npm package](https://www.npmjs.com/package/@aponiajs/platform-elysia) ·
|
|
45
67
|
[complete package catalog](../../docs/packages.md)
|
package/dist/index.d.mts
CHANGED
|
@@ -5,19 +5,24 @@ type AponiaRootModule = ModuleClass | ModuleDefinition;
|
|
|
5
5
|
declare function compileRootModule(rootModule: AponiaRootModule): ModuleDefinition;
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/application.d.ts
|
|
8
|
-
declare class AponiaElysiaApplication {
|
|
8
|
+
declare class AponiaElysiaApplication<TNativeApplication extends AnyElysia = Elysia> {
|
|
9
9
|
#private;
|
|
10
|
-
constructor(nativeApplication:
|
|
11
|
-
getNativeApplication():
|
|
10
|
+
constructor(nativeApplication: TNativeApplication, logger: LoggerService | undefined);
|
|
11
|
+
getNativeApplication(): TNativeApplication;
|
|
12
12
|
handle(request: Request): Response | Promise<Response>;
|
|
13
13
|
listen(port: number): Promise<void>;
|
|
14
14
|
getUrl(): string;
|
|
15
15
|
close(): Promise<void>;
|
|
16
16
|
}
|
|
17
|
+
type NativeElysiaConfigurator<TNativeApplication extends AnyElysia> = (application: Elysia) => TNativeApplication;
|
|
17
18
|
interface AponiaApplicationOptions {
|
|
18
19
|
readonly logger?: false | LoggerService | readonly LogLevel[];
|
|
19
20
|
}
|
|
21
|
+
interface ConfiguredAponiaApplicationOptions<TNativeApplication extends AnyElysia> extends AponiaApplicationOptions {
|
|
22
|
+
readonly configureNative: NativeElysiaConfigurator<TNativeApplication>;
|
|
23
|
+
}
|
|
20
24
|
declare class AponiaFactory {
|
|
25
|
+
static create<const TNativeApplication extends AnyElysia>(rootModule: AponiaRootModule, options: ConfiguredAponiaApplicationOptions<TNativeApplication>): Promise<AponiaElysiaApplication<TNativeApplication>>;
|
|
21
26
|
static create(rootModule: AponiaRootModule, options?: AponiaApplicationOptions): Promise<AponiaElysiaApplication>;
|
|
22
27
|
}
|
|
23
28
|
//#endregion
|
|
@@ -34,4 +39,4 @@ declare function defineElysiaController<TController, const TDependencies extends
|
|
|
34
39
|
readonly buildPlugin: (controller: TController) => TPlugin;
|
|
35
40
|
}): ElysiaControllerDefinition<TController, TDependencies, TPlugin>;
|
|
36
41
|
//#endregion
|
|
37
|
-
export { type AponiaApplicationOptions, AponiaElysiaApplication, AponiaFactory, type AponiaRootModule, ELYSIA_CONTROLLER, type ElysiaControllerDefinition, compileRootModule, defineElysiaController };
|
|
42
|
+
export { type AponiaApplicationOptions, AponiaElysiaApplication, AponiaFactory, type AponiaRootModule, type ConfiguredAponiaApplicationOptions, ELYSIA_CONTROLLER, type ElysiaControllerDefinition, type NativeElysiaConfigurator, compileRootModule, defineElysiaController };
|
package/dist/index.mjs
CHANGED
|
@@ -127,7 +127,10 @@ var AponiaFactory = class {
|
|
|
127
127
|
logger?.log("Starting Aponia application...", "AponiaFactory");
|
|
128
128
|
const compiledRootModule = compileRootModule(rootModule);
|
|
129
129
|
const container = createContainer(compiledRootModule);
|
|
130
|
-
const
|
|
130
|
+
const baseApplication = new Elysia({ name: compiledRootModule.id });
|
|
131
|
+
const configureNative = "configureNative" in options ? options.configureNative : void 0;
|
|
132
|
+
const nativeApplication = configureNative ? configureNative(baseApplication) : baseApplication;
|
|
133
|
+
if (nativeApplication !== baseApplication) throw new AponiaError("INVALID_NATIVE_APPLICATION", "configureNative must return the Elysia application it receives.");
|
|
131
134
|
for (const module of container.graph.modules) {
|
|
132
135
|
container.initializeModule(module);
|
|
133
136
|
logger?.log(`${module.id} dependencies initialized`, "InstanceLoader");
|
|
@@ -146,10 +149,12 @@ var AponiaFactory = class {
|
|
|
146
149
|
module: module.id,
|
|
147
150
|
controller: tokenName(controller.token)
|
|
148
151
|
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
if (logger) {
|
|
153
|
+
const controllerName = tokenName(controller.token);
|
|
154
|
+
const controllerPath = controller.path ?? inferControllerPath(plugin);
|
|
155
|
+
logger.log(`${controllerName} {${controllerPath}}:`, "RoutesResolver");
|
|
156
|
+
for (const route of plugin.routes) logger.log(`Mapped {${route.path}, ${String(route.method).toUpperCase()}} route`, "RouterExplorer");
|
|
157
|
+
}
|
|
153
158
|
nativeApplication.use(plugin);
|
|
154
159
|
}
|
|
155
160
|
await nativeApplication.modules;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aponiajs/platform-elysia",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.18",
|
|
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,8 +33,8 @@
|
|
|
33
33
|
"prepublishOnly": "bun run build"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@aponiajs/common": "0.3.
|
|
37
|
-
"@aponiajs/core": "0.3.
|
|
36
|
+
"@aponiajs/common": "0.3.18",
|
|
37
|
+
"@aponiajs/core": "0.3.18"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"elysia": "^1.4.29"
|