30ec231aaf
deploy / deploy (push) Has been cancelled
nix-eval / nix-eval (push) Has been cancelled
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404, x86_64-linux) (push) Has been cancelled
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404-arm, aarch64-linux) (push) Has been cancelled
nix-hashes / compute-hash (macos-15-intel, x86_64-darwin) (push) Has been cancelled
nix-hashes / compute-hash (macos-latest, aarch64-darwin) (push) Has been cancelled
nix-hashes / update-hashes (push) Has been cancelled
publish / version (push) Has been cancelled
publish / build-cli (push) Has been cancelled
publish / sign-cli-windows (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=arm64 host:macos-26 platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=x64 host:macos-26-intel platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404-arm platform_flag:--linux --arm64 target:aarch64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Has been cancelled
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
publish / publish (push) Has been cancelled
storybook / storybook build (push) Has been cancelled
containers / build (push) Has been cancelled
docs-locale-sync / sync-locales (push) Has been cancelled
generate / generate (push) Has been cancelled
typecheck / typecheck (push) Has been cancelled
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import { Database } from "@opencode-ai/core/database/database"
|
|
import { EventV2 } from "@opencode-ai/core/event"
|
|
import { LocationServiceMap } from "@opencode-ai/core/location-layer"
|
|
import { PermissionSaved } from "@opencode-ai/core/permission/saved"
|
|
import { SessionV2 } from "@opencode-ai/core/session"
|
|
import { FetchHttpClient, HttpRouter, HttpServer } from "effect/unstable/http"
|
|
import { HttpApiBuilder } from "effect/unstable/httpapi"
|
|
import { Layer, Option } from "effect"
|
|
import { V2Api } from "./api"
|
|
import { ServerAuth } from "./auth"
|
|
import { v2Handlers } from "./handlers"
|
|
import { v2AuthorizationLayer } from "./middleware/authorization"
|
|
import { schemaErrorLayer } from "./middleware/schema-error"
|
|
|
|
export function createRoutes(password?: string) {
|
|
return HttpApiBuilder.layer(V2Api).pipe(
|
|
Layer.provide(v2Handlers),
|
|
Layer.provide(v2AuthorizationLayer),
|
|
Layer.provide(schemaErrorLayer),
|
|
Layer.provide(
|
|
password
|
|
? ServerAuth.Config.layer({ username: "opencode", password: Option.some(password) })
|
|
: ServerAuth.Config.defaultLayer,
|
|
),
|
|
Layer.provide(LocationServiceMap.layer),
|
|
Layer.provide(PermissionSaved.layer),
|
|
Layer.provide(SessionV2.defaultLayer),
|
|
Layer.provide(Database.defaultLayer),
|
|
Layer.provide(EventV2.defaultLayer),
|
|
Layer.provide(FetchHttpClient.layer),
|
|
)
|
|
}
|
|
|
|
export const routes = createRoutes()
|
|
|
|
export const webHandler = () =>
|
|
HttpRouter.toWebHandler(routes.pipe(Layer.provide(HttpServer.layerServices)), { disableLogger: true })
|