Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
27 changes: 27 additions & 0 deletions packages/plugins/server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# @objectql/plugin-server

## 3.0.1

### Added

- Initial release as an ObjectQL plugin
- Support for JSON-RPC, REST, GraphQL, and Metadata APIs
- Hono framework adapter
- Express/Node.js adapter
- Plugin-based architecture
- Configurable routes and middleware
- File upload/download support
- Auto-start capability
- Backward compatibility with @objectql/server

### Changed

- Refactored server functionality into plugin architecture
- Improved modularity and extensibility
- Enhanced framework integration support

### Documentation

- Added comprehensive README with examples
- Documented all configuration options
- Included usage examples for Hono, Express, and standalone usage
126 changes: 126 additions & 0 deletions packages/plugins/server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# @objectql/plugin-server

HTTP server plugin for ObjectQL. Provides Express, Hono, and custom HTTP server support with JSON-RPC, REST, GraphQL, and Metadata APIs.

## Installation

```bash
npm install @objectql/plugin-server
```

## Usage

### As a Plugin

```typescript
import { ObjectQL } from '@objectql/core';
import { ServerPlugin } from '@objectql/plugin-server';

const app = new ObjectQL({
datasources: { /* ... */ },
plugins: [
new ServerPlugin({
port: 3000,
autoStart: true,
enableREST: true,
enableRPC: true,
enableMetadata: true
})
]
});

await app.init();
```

### With Hono Framework

```typescript
import { Hono } from 'hono';
import { ObjectQL } from '@objectql/core';
import { createHonoAdapter } from '@objectql/plugin-server/adapters/hono';

const app = new ObjectQL({ /* ... */ });
await app.init();

const server = new Hono();
const objectqlHandler = createHonoAdapter(app);

server.all('/api/*', objectqlHandler);

export default server;
```

### With Express

```typescript
import express from 'express';
import { ObjectQL } from '@objectql/core';
import { createNodeHandler } from '@objectql/plugin-server';

const app = new ObjectQL({ /* ... */ });
await app.init();

const server = express();
const objectqlHandler = createNodeHandler(app);

server.all('/api/*', objectqlHandler);

server.listen(3000);
```

## Features

### JSON-RPC API
- Protocol-first approach
- Supports all ObjectQL operations
- Type-safe requests and responses

### REST API
- Standard HTTP methods (GET, POST, PUT, DELETE)
- RESTful resource endpoints
- Query parameter support

### GraphQL API
- Auto-generated schema from ObjectQL metadata
- Support for queries and mutations
- Introspection support

### Metadata API
- Explore object schemas
- Discover available operations
- Runtime schema inspection

### File Upload/Download
- Single and batch file uploads
- Secure file storage
- File download support

## Configuration Options

```typescript
interface ServerPluginOptions {
port?: number; // Default: 3000
host?: string; // Default: 'localhost'
routes?: ApiRouteConfig; // Custom route configuration
fileStorage?: IFileStorage; // Custom file storage
enableGraphQL?: boolean; // Default: false
enableREST?: boolean; // Default: true
enableMetadata?: boolean; // Default: true
enableRPC?: boolean; // Default: true
autoStart?: boolean; // Default: false
middleware?: Function[]; // Custom middleware
}
```

## API Routes

Default routes (customizable):
- JSON-RPC: `/api/objectql`
- REST: `/api/data`
- GraphQL: `/api/graphql`
- Metadata: `/api/metadata`
- Files: `/api/files`

## License

MIT
7 changes: 7 additions & 0 deletions packages/plugins/server/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/test'],
testMatch: ['**/*.test.ts'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
};
46 changes: 46 additions & 0 deletions packages/plugins/server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@objectql/plugin-server",
"version": "3.0.1",
"description": "HTTP server plugin for ObjectQL - Provides Express, Hono and REST API support",
"keywords": [
"objectql",
"plugin",
"server",
"http",
"api",
"rest",
"graphql",
"express",
"hono",
"adapter",
"backend"
],
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"test": "jest"
},
"dependencies": {
"@objectql/core": "workspace:*",
"@objectql/types": "workspace:*",
"graphql": "^16.8.1",
"@graphql-tools/schema": "^10.0.2",
"js-yaml": "^4.1.1"
},
"peerDependencies": {
"hono": "^4.11.0"
},
"peerDependenciesMeta": {
"hono": {
"optional": true
}
},
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.10.0",
"hono": "^4.11.0",
"typescript": "^5.3.0"
}
}
Loading