@objectstack/plugin-hono-server 1.0.2 → 1.0.5
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/.turbo/turbo-build.log +22 -0
- package/CHANGELOG.md +50 -0
- package/dist/index.d.mts +88 -0
- package/dist/index.d.ts +88 -2
- package/dist/index.js +256 -15
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +256 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +7 -7
- package/src/adapter.ts +8 -1
- package/src/hono-plugin.test.ts +30 -1
- package/src/hono-plugin.ts +51 -6
- package/dist/adapter.d.ts +0 -27
- package/dist/adapter.js +0 -139
- package/dist/hono-plugin.d.ts +0 -49
- package/dist/hono-plugin.js +0 -86
package/dist/hono-plugin.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Plugin, PluginContext } from '@objectstack/core';
|
|
2
|
-
import { RestServerConfig } from '@objectstack/spec/api';
|
|
3
|
-
export interface HonoPluginOptions {
|
|
4
|
-
port?: number;
|
|
5
|
-
staticRoot?: string;
|
|
6
|
-
/**
|
|
7
|
-
* REST server configuration
|
|
8
|
-
* Controls automatic endpoint generation and API behavior
|
|
9
|
-
*/
|
|
10
|
-
restConfig?: RestServerConfig;
|
|
11
|
-
/**
|
|
12
|
-
* Whether to register standard ObjectStack CRUD endpoints
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
registerStandardEndpoints?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Whether to load endpoints from API Registry
|
|
18
|
-
* @default true
|
|
19
|
-
*/
|
|
20
|
-
useApiRegistry?: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Hono Server Plugin
|
|
24
|
-
*
|
|
25
|
-
* Provides HTTP server capabilities using Hono framework.
|
|
26
|
-
* Registers routes for ObjectStack Runtime Protocol.
|
|
27
|
-
*/
|
|
28
|
-
export declare class HonoServerPlugin implements Plugin {
|
|
29
|
-
name: string;
|
|
30
|
-
version: string;
|
|
31
|
-
private static readonly DEFAULT_ENDPOINT_PRIORITY;
|
|
32
|
-
private static readonly CORE_ENDPOINT_PRIORITY;
|
|
33
|
-
private static readonly DISCOVERY_ENDPOINT_PRIORITY;
|
|
34
|
-
private options;
|
|
35
|
-
private server;
|
|
36
|
-
constructor(options?: HonoPluginOptions);
|
|
37
|
-
/**
|
|
38
|
-
* Init phase - Setup HTTP server and register as service
|
|
39
|
-
*/
|
|
40
|
-
init: (ctx: PluginContext) => Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* Start phase - Bind routes and start listening
|
|
43
|
-
*/
|
|
44
|
-
start: (ctx: PluginContext) => Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Destroy phase - Stop server
|
|
47
|
-
*/
|
|
48
|
-
destroy(): Promise<void>;
|
|
49
|
-
}
|
package/dist/hono-plugin.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HonoServerPlugin = void 0;
|
|
4
|
-
const adapter_1 = require("./adapter");
|
|
5
|
-
const hono_1 = require("@objectstack/hono");
|
|
6
|
-
/**
|
|
7
|
-
* Hono Server Plugin
|
|
8
|
-
*
|
|
9
|
-
* Provides HTTP server capabilities using Hono framework.
|
|
10
|
-
* Registers routes for ObjectStack Runtime Protocol.
|
|
11
|
-
*/
|
|
12
|
-
class HonoServerPlugin {
|
|
13
|
-
name = 'com.objectstack.server.hono';
|
|
14
|
-
version = '0.9.0';
|
|
15
|
-
// Constants
|
|
16
|
-
static DEFAULT_ENDPOINT_PRIORITY = 100;
|
|
17
|
-
static CORE_ENDPOINT_PRIORITY = 950;
|
|
18
|
-
static DISCOVERY_ENDPOINT_PRIORITY = 900;
|
|
19
|
-
options;
|
|
20
|
-
server;
|
|
21
|
-
constructor(options = {}) {
|
|
22
|
-
this.options = {
|
|
23
|
-
port: 3000,
|
|
24
|
-
registerStandardEndpoints: true,
|
|
25
|
-
useApiRegistry: true,
|
|
26
|
-
...options
|
|
27
|
-
};
|
|
28
|
-
this.server = new adapter_1.HonoHttpServer(this.options.port, this.options.staticRoot);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Init phase - Setup HTTP server and register as service
|
|
32
|
-
*/
|
|
33
|
-
init = async (ctx) => {
|
|
34
|
-
ctx.logger.debug('Initializing Hono server plugin', {
|
|
35
|
-
port: this.options.port,
|
|
36
|
-
staticRoot: this.options.staticRoot
|
|
37
|
-
});
|
|
38
|
-
// Register HTTP server service as IHttpServer
|
|
39
|
-
ctx.registerService('http-server', this.server);
|
|
40
|
-
ctx.logger.info('HTTP server service registered', { serviceName: 'http-server' });
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Start phase - Bind routes and start listening
|
|
44
|
-
*/
|
|
45
|
-
start = async (ctx) => {
|
|
46
|
-
ctx.logger.debug('Starting Hono server plugin');
|
|
47
|
-
// Use Standard ObjectStack Runtime Hono App
|
|
48
|
-
try {
|
|
49
|
-
const kernel = ctx.getKernel();
|
|
50
|
-
const config = this.options.restConfig || {};
|
|
51
|
-
// Calculate prefix similar to before
|
|
52
|
-
const apiVersion = config.api?.version || 'v1';
|
|
53
|
-
const basePath = config.api?.basePath || '/api';
|
|
54
|
-
const apiPath = config.api?.apiPath || `${basePath}/${apiVersion}`;
|
|
55
|
-
const app = (0, hono_1.createHonoApp)({
|
|
56
|
-
kernel,
|
|
57
|
-
prefix: apiPath // Use the calculated path
|
|
58
|
-
});
|
|
59
|
-
ctx.logger.info('Mounting ObjectStack Runtime App', { prefix: apiPath });
|
|
60
|
-
// Use the mount method we added to HonoHttpServer
|
|
61
|
-
this.server.mount('/', app);
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
ctx.logger.error('Failed to create standard Hono app', e);
|
|
65
|
-
}
|
|
66
|
-
// Start server on kernel:ready hook
|
|
67
|
-
ctx.hook('kernel:ready', async () => {
|
|
68
|
-
const port = this.options.port || 3000;
|
|
69
|
-
ctx.logger.info('Starting HTTP server', { port });
|
|
70
|
-
await this.server.listen(port);
|
|
71
|
-
ctx.logger.info('HTTP server started successfully', {
|
|
72
|
-
port,
|
|
73
|
-
url: `http://localhost:${port}`
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Destroy phase - Stop server
|
|
79
|
-
*/
|
|
80
|
-
async destroy() {
|
|
81
|
-
this.server.close();
|
|
82
|
-
// Note: Can't use ctx.logger here since we're in destroy
|
|
83
|
-
console.log('[HonoServerPlugin] Server stopped');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.HonoServerPlugin = HonoServerPlugin;
|