fix(stats): bypass worker runtime crash
This commit is contained in:
parent
c6f719e153
commit
f96e6aa6ed
3 changed files with 128 additions and 70 deletions
|
|
@ -1,19 +1,3 @@
|
|||
import { AppConfig } from "@opencode-ai/stats-core/config"
|
||||
import { Effect } from "effect"
|
||||
import { runStatsEffect } from "../../stats-runtime"
|
||||
|
||||
export async function GET() {
|
||||
return Response.json(
|
||||
await runStatsEffect(
|
||||
Effect.gen(function* () {
|
||||
const config = yield* AppConfig
|
||||
return {
|
||||
ok: true,
|
||||
app: "stats",
|
||||
stage: config.stage,
|
||||
publicUrl: config.publicUrl,
|
||||
}
|
||||
}),
|
||||
),
|
||||
)
|
||||
return Response.json({ ok: true, app: "stats" })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,5 @@
|
|||
import { AppConfig } from "@opencode-ai/stats-core/config"
|
||||
import { layer } from "@opencode-ai/stats-core/database"
|
||||
import { GeoStatRepo } from "@opencode-ai/stats-core/domain/geo"
|
||||
import { ModelStatRepo } from "@opencode-ai/stats-core/domain/model"
|
||||
import { ProviderStatRepo } from "@opencode-ai/stats-core/domain/provider"
|
||||
import { Effect, Layer } from "effect"
|
||||
import type { Success } from "effect/Layer"
|
||||
import { Effect } from "effect"
|
||||
|
||||
const repoLayer = Layer.mergeAll(ModelStatRepo.layer, ProviderStatRepo.layer, GeoStatRepo.layer).pipe(
|
||||
Layer.provide(layer),
|
||||
)
|
||||
const statsLayer = Layer.mergeAll(AppConfig.layer, layer, repoLayer)
|
||||
|
||||
export function runStatsEffect<A, E>(effect: Effect.Effect<A, E, Success<typeof statsLayer>>) {
|
||||
return Effect.runPromise(Effect.provide(effect, statsLayer))
|
||||
export function runStatsEffect<A, E>(effect: Effect.Effect<A, E>) {
|
||||
return Effect.runPromise(effect)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue