More smoothing, as they say
This commit is contained in:
@@ -5,17 +5,24 @@ pub mod context;
|
||||
pub mod fs;
|
||||
pub mod health;
|
||||
pub mod model;
|
||||
pub mod payloads;
|
||||
|
||||
pub mod project;
|
||||
pub mod rest;
|
||||
pub mod search;
|
||||
pub mod shell;
|
||||
pub mod ws;
|
||||
|
||||
use crate::http::context::AppContext;
|
||||
use crate::http::rest::build_openapi_service;
|
||||
use anthropic::AnthropicApi;
|
||||
use chat::ChatApi;
|
||||
use context::AppContext;
|
||||
use fs::FsApi;
|
||||
use model::ModelApi;
|
||||
use poem::EndpointExt;
|
||||
use poem::{Route, get};
|
||||
use poem_openapi::OpenApiService;
|
||||
use project::ProjectApi;
|
||||
use search::SearchApi;
|
||||
use shell::ShellApi;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn build_routes(ctx: AppContext) -> impl poem::Endpoint {
|
||||
let ctx_arc = std::sync::Arc::new(ctx);
|
||||
@@ -32,3 +39,45 @@ pub fn build_routes(ctx: AppContext) -> impl poem::Endpoint {
|
||||
.at("/*path", get(assets::embedded_file))
|
||||
.data(ctx_arc)
|
||||
}
|
||||
|
||||
type ApiTuple = (
|
||||
ProjectApi,
|
||||
ModelApi,
|
||||
AnthropicApi,
|
||||
FsApi,
|
||||
SearchApi,
|
||||
ShellApi,
|
||||
ChatApi,
|
||||
);
|
||||
|
||||
type ApiService = OpenApiService<ApiTuple, ()>;
|
||||
|
||||
pub fn build_openapi_service(ctx: Arc<AppContext>) -> (ApiService, ApiService) {
|
||||
let api = (
|
||||
ProjectApi { ctx: ctx.clone() },
|
||||
ModelApi { ctx: ctx.clone() },
|
||||
AnthropicApi::new(ctx.clone()),
|
||||
FsApi { ctx: ctx.clone() },
|
||||
SearchApi { ctx: ctx.clone() },
|
||||
ShellApi { ctx: ctx.clone() },
|
||||
ChatApi { ctx: ctx.clone() },
|
||||
);
|
||||
|
||||
let api_service =
|
||||
OpenApiService::new(api, "Story Kit API", "1.0").server("http://127.0.0.1:3001/api");
|
||||
|
||||
let docs_api = (
|
||||
ProjectApi { ctx: ctx.clone() },
|
||||
ModelApi { ctx: ctx.clone() },
|
||||
AnthropicApi::new(ctx.clone()),
|
||||
FsApi { ctx: ctx.clone() },
|
||||
SearchApi { ctx: ctx.clone() },
|
||||
ShellApi { ctx: ctx.clone() },
|
||||
ChatApi { ctx },
|
||||
);
|
||||
|
||||
let docs_service =
|
||||
OpenApiService::new(docs_api, "Story Kit API", "1.0").server("http://127.0.0.1:3001/api");
|
||||
|
||||
(api_service, docs_service)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user