mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
Refactor ServerCoordinator
and project structure for clearer durable objects organization and module imports.
This commit is contained in:
20
packages/server/README.md
Normal file
20
packages/server/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# @open-gsio/server
|
||||
|
||||
This directory contains the server component of open-gsio, a full-stack Conversational AI application. The server handles API requests, manages AI model interactions, serves static assets, and provides server-side rendering capabilities.
|
||||
|
||||
## Directory Structure
|
||||
|
||||
- `__tests__/`: Contains test files for the server components
|
||||
- `services/`: Contains service modules for different functionalities
|
||||
- `AssetService.ts`: Handles static assets and SSR
|
||||
- `ChatService.ts`: Manages chat interactions with AI models
|
||||
- `ContactService.ts`: Processes contact form submissions
|
||||
- `FeedbackService.ts`: Handles user feedback
|
||||
- `MetricsService.ts`: Collects and processes metrics
|
||||
- `TransactionService.ts`: Manages transactions
|
||||
- `durable_objects/`: Contains durable object implementations
|
||||
- `ServerCoordinator.ts`: Cloudflare Implementation
|
||||
- `ServerCoordinatorBun.ts`: Bun Implementation
|
||||
- `api-router.ts`: API Router
|
||||
- `RequestContext.ts`: Application Context
|
||||
- `server.ts`: Main server entry point
|
@@ -1,5 +1,5 @@
|
||||
import { DurableObject } from "cloudflare:workers";
|
||||
import {ProviderRepository} from "./providers/_ProviderRepository";
|
||||
import {ProviderRepository} from "../providers/_ProviderRepository";
|
||||
|
||||
export default class ServerCoordinator extends DurableObject {
|
||||
env;
|
@@ -1,4 +1,4 @@
|
||||
import {BunSqliteKVNamespace} from "./storage/BunSqliteKVNamespace";
|
||||
import {BunSqliteKVNamespace} from "../storage/BunSqliteKVNamespace";
|
||||
|
||||
|
||||
class BunDurableObject {
|
@@ -2,9 +2,10 @@ import {BunSqliteKVNamespace} from "./storage/BunSqliteKVNamespace";
|
||||
import {readdir} from 'node:fs/promises';
|
||||
import type { RequestLike } from "itty-router";
|
||||
|
||||
import {config} from "dotenv";
|
||||
import ServerCoordinator from "./durable-objects/ServerCoordinatorBun";
|
||||
import Server from ".";
|
||||
import DurableObjectLocal from "./ServerCoordinatorBun";
|
||||
|
||||
import {config} from "dotenv";
|
||||
|
||||
const router = Server.Router();
|
||||
|
||||
@@ -21,7 +22,7 @@ export default {
|
||||
fetch: async (request: RequestLike, env: { [key: string]: any; }, ctx: any) =>{
|
||||
// console.log("[trace] request: ", request.method, request.url, "headers: ", request.headers.get("referer"), "body: ", request.body, "env: ", env, "ctx: ", ctx, "")
|
||||
|
||||
env["SERVER_COORDINATOR"] = DurableObjectLocal;
|
||||
env["SERVER_COORDINATOR"] = ServerCoordinator;
|
||||
env["ASSETS"] = assetHandler.ASSETS;
|
||||
env["EVENTSOURCE_HOST"] = process.env.EVENTSOURCE_HOST;
|
||||
env["GROQ_API_KEY"] = process.env.GROQ_API_KEY;
|
||||
@@ -57,7 +58,7 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
const assetHandler = {
|
||||
export const assetHandler = {
|
||||
ASSETS: {
|
||||
/**
|
||||
* Fetches the requested static asset from local dist
|
||||
|
Reference in New Issue
Block a user