Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,21 @@ new AppManifestPlugin(appConfig)

#### IHttpServer

Abstract interface for HTTP server capabilities. Allows plugins to work with any HTTP framework (Express, Fastify, Hono, etc.) without tight coupling.
Abstract interface for HTTP server capabilities.

**Primary Implementation:** Hono (@objectstack/plugin-hono-server) is the canonical HTTP framework for ObjectStack - lightweight, fast, and edge-ready.

**Alternative Implementations:** Express, Fastify, Koa, etc. can also implement this interface.

```typescript
import { IHttpServer, IHttpRequest, IHttpResponse } from '@objectstack/runtime';

// In your HTTP server plugin
// In your HTTP server plugin (using Hono or any other framework)
class MyHttpServerPlugin implements Plugin {
name = 'http-server';

async init(ctx: PluginContext) {
const server: IHttpServer = createMyServer(); // Express, Hono, etc.
const server: IHttpServer = createMyServer(); // Hono, Express, etc.
ctx.registerService('http-server', server);
}
}
Expand Down Expand Up @@ -169,12 +173,16 @@ class MyApiPlugin implements Plugin {

#### IDataEngine

Abstract interface for data persistence. Allows plugins to work with any data layer (ObjectQL, Prisma, TypeORM, etc.) without tight coupling.
Abstract interface for data persistence.

**Primary Implementation:** ObjectQL (@objectstack/objectql) is the canonical data engine for ObjectStack - provides metadata-driven CRUD operations with driver abstraction.

**Alternative Implementations:** Prisma, TypeORM, Mongoose, etc. can also implement this interface.

```typescript
import { IDataEngine } from '@objectstack/runtime';

// In your data plugin
// In your data plugin (using ObjectQL or any other data layer)
class MyDataPlugin implements Plugin {
name = 'data';

Expand Down
12 changes: 10 additions & 2 deletions packages/runtime/src/interfaces/data-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
*
* Abstract interface for data persistence capabilities.
* This allows plugins to interact with data engines without knowing
* the underlying implementation (SQL, MongoDB, Memory, etc.).
* the underlying implementation.
*
* **Primary Implementation:** ObjectQL (@objectstack/objectql)
* - ObjectQL is the canonical data engine for ObjectStack
* - Provides metadata-driven CRUD operations with driver abstraction
*
* **Alternative Implementations:** Prisma, TypeORM, Mongoose, etc.
*
* Follows Dependency Inversion Principle - plugins depend on this interface,
* not on concrete database implementations.
Expand Down Expand Up @@ -38,7 +44,9 @@ export interface QueryOptions {
* IDataEngine - Data persistence capability interface
*
* Defines the contract for data engine implementations.
* Concrete implementations (ObjectQL, Prisma, TypeORM) should implement this interface.
*
* **Primary Implementation:** ObjectQL is the canonical implementation for ObjectStack.
* Alternative implementations (Prisma, TypeORM) can also implement this interface.
*/
export interface IDataEngine {
/**
Expand Down
12 changes: 10 additions & 2 deletions packages/runtime/src/interfaces/http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
*
* Abstract interface for HTTP server capabilities.
* This allows plugins to interact with HTTP servers without knowing
* the underlying implementation (Express, Fastify, Hono, etc.).
* the underlying implementation.
*
* **Primary Implementation:** Hono (@objectstack/plugin-hono-server)
* - Hono is the canonical HTTP framework for ObjectStack
* - Lightweight, fast, and edge-ready
*
* **Alternative Implementations:** Express, Fastify, Koa, etc.
*
* Follows Dependency Inversion Principle - plugins depend on this interface,
* not on concrete HTTP framework implementations.
Expand Down Expand Up @@ -80,7 +86,9 @@ export type Middleware = (
* IHttpServer - HTTP Server capability interface
*
* Defines the contract for HTTP server implementations.
* Concrete implementations (Express, Fastify, Hono) should implement this interface.
*
* **Primary Implementation:** Hono is the canonical implementation for ObjectStack.
* Alternative implementations (Express, Fastify) can also implement this interface.
*/
export interface IHttpServer {
/**
Expand Down
20 changes: 16 additions & 4 deletions packages/runtime/src/test-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@
*
* This file demonstrates how plugins can implement the IHttpServer
* and IDataEngine interfaces without depending on concrete implementations.
*
* Primary Implementations in ObjectStack:
* - IHttpServer → Hono (@objectstack/plugin-hono-server)
* - IDataEngine → ObjectQL (@objectstack/objectql)
*
* This mock implementation is for testing purposes only.
*/

import { IHttpServer, IDataEngine, RouteHandler, IHttpRequest, IHttpResponse, Middleware, QueryOptions } from './index.js';

/**
* Example: Mock HTTP Server Plugin
*
* Shows how a plugin can implement the IHttpServer interface
* without depending on Express, Fastify, or any specific framework.
* Shows how a plugin can implement the IHttpServer interface.
*
* Note: In production ObjectStack applications, use Hono via
* @objectstack/plugin-hono-server as the canonical implementation.
* This mock is for testing the interface contract only.
*/
class MockHttpServer implements IHttpServer {
private routes: Map<string, { method: string; handler: RouteHandler }> = new Map();
Expand Down Expand Up @@ -57,8 +66,11 @@ class MockHttpServer implements IHttpServer {
/**
* Example: Mock Data Engine Plugin
*
* Shows how a plugin can implement the IDataEngine interface
* without depending on ObjectQL, Prisma, or any specific database.
* Shows how a plugin can implement the IDataEngine interface.
*
* Note: In production ObjectStack applications, use ObjectQL via
* @objectstack/objectql as the canonical implementation.
* This mock is for testing the interface contract only.
*/
class MockDataEngine implements IDataEngine {
private store: Map<string, Map<string, any>> = new Map();
Expand Down