@@ -6,8 +6,6 @@ import { logger } from 'hono/logger';
66import {
77 Plugin ,
88 PluginContext ,
9- RuntimePlugin ,
10- RuntimeContext ,
119 ObjectStackRuntimeProtocol
1210} from '@objectstack/runtime' ;
1311
@@ -30,7 +28,7 @@ export interface HonoPluginOptions {
3028 * const server = new HonoServerPlugin({ port: 3000 });
3129 * kernel.use(server);
3230 */
33- export class HonoServerPlugin implements Plugin , RuntimePlugin {
31+ export class HonoServerPlugin implements Plugin {
3432 name = 'com.objectstack.server.hono' ;
3533 version = '1.0.0' ;
3634
@@ -116,111 +114,4 @@ export class HonoServerPlugin implements Plugin, RuntimePlugin {
116114 console . log ( '[HonoServerPlugin] Server stopped' ) ;
117115 }
118116 }
119-
120- /**
121- * Legacy install method for backward compatibility
122- * @deprecated Use init/start lifecycle hooks instead
123- */
124- install ( ctx : RuntimeContext ) {
125- const { engine } = ctx ;
126- const protocol = new ObjectStackRuntimeProtocol ( engine ) ;
127-
128- // --- Bind Protocol to Hono ---
129-
130- // 1. Discovery
131- this . app . get ( '/api/v1' , ( c ) => c . json ( protocol . getDiscovery ( ) ) ) ;
132-
133- // 2. Meta
134- this . app . get ( '/api/v1/meta' , ( c ) => c . json ( protocol . getMetaTypes ( ) ) ) ;
135- this . app . get ( '/api/v1/meta/:type' , ( c ) => c . json ( protocol . getMetaItems ( c . req . param ( 'type' ) ) ) ) ;
136- this . app . get ( '/api/v1/meta/:type/:name' , ( c ) => {
137- try {
138- return c . json ( protocol . getMetaItem ( c . req . param ( 'type' ) , c . req . param ( 'name' ) ) ) ;
139- } catch ( e : any ) {
140- return c . json ( { error : e . message } , 404 ) ;
141- }
142- } ) ;
143-
144- // 3. Data
145- this . app . get ( '/api/v1/data/:object' , async ( c ) => {
146- try {
147- const result = await protocol . findData ( c . req . param ( 'object' ) , c . req . query ( ) ) ;
148- return c . json ( result ) ;
149- } catch ( e : any ) {
150- return c . json ( { error : e . message } , 404 ) ;
151- }
152- } ) ;
153-
154- this . app . get ( '/api/v1/data/:object/:id' , async ( c ) => {
155- try {
156- const result = await protocol . getData ( c . req . param ( 'object' ) , c . req . param ( 'id' ) ) ;
157- return c . json ( result ) ;
158- } catch ( e : any ) {
159- return c . json ( { error : e . message } , 404 ) ;
160- }
161- } ) ;
162-
163- this . app . post ( '/api/v1/data/:object' , async ( c ) => {
164- try {
165- const body = await c . req . json ( ) ;
166- const result = await protocol . createData ( c . req . param ( 'object' ) , body ) ;
167- return c . json ( result , 201 ) ;
168- } catch ( e : any ) {
169- return c . json ( { error : e . message } , 400 ) ;
170- }
171- } ) ;
172-
173- this . app . patch ( '/api/v1/data/:object/:id' , async ( c ) => {
174- try {
175- const body = await c . req . json ( ) ;
176- const result = await protocol . updateData ( c . req . param ( 'object' ) , c . req . param ( 'id' ) , body ) ;
177- return c . json ( result ) ;
178- } catch ( e : any ) {
179- return c . json ( { error : e . message } , 400 ) ;
180- }
181- } ) ;
182-
183- this . app . delete ( '/api/v1/data/:object/:id' , async ( c ) => {
184- try {
185- const result = await protocol . deleteData ( c . req . param ( 'object' ) , c . req . param ( 'id' ) ) ;
186- return c . json ( result ) ;
187- } catch ( e : any ) {
188- return c . json ( { error : e . message } , 400 ) ;
189- }
190- } ) ;
191-
192- // 4. UI Protocol
193- this . app . get ( '/api/v1/ui/view/:object' , ( c ) => {
194- try {
195- // @ts -ignore
196- const view = protocol . getUiView ( c . req . param ( 'object' ) , c . req . query ( 'type' ) || 'list' ) ;
197- return c . json ( view ) ;
198- } catch ( e : any ) {
199- return c . json ( { error : e . message } , 404 ) ;
200- }
201- } ) ;
202-
203- // Static Files
204- if ( this . options . staticRoot ) {
205- this . app . get ( '/' , serveStatic ( { root : this . options . staticRoot , path : 'index.html' } ) ) ;
206- this . app . get ( '/*' , serveStatic ( { root : this . options . staticRoot } ) ) ;
207- }
208-
209- console . log ( `[HonoPlugin] Installed routes and middleware.` ) ;
210- }
211-
212- /**
213- * Legacy onStart method for backward compatibility
214- * @deprecated Use start lifecycle hook instead
215- */
216- async onStart ( ctx : RuntimeContext ) {
217- const port = this . options . port ;
218- console . log ( `[HonoPlugin] Starting server...` ) ;
219- console . log ( `✅ Server is running on http://localhost:${ port } ` ) ;
220-
221- serve ( {
222- fetch : this . app . fetch ,
223- port
224- } ) ;
225- }
226117}
0 commit comments