mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-21 01:21:17 +00:00
Replace per-source services (LocationService, WeatherService, TflService, FeedEngineService) with a single UserSessionManager that owns all per-user state. Source creation is delegated to thin FeedSourceProvider implementations per source type. Co-authored-by: Ona <no-reply@ona.com>
29 lines
714 B
TypeScript
29 lines
714 B
TypeScript
import { type } from "arktype"
|
|
|
|
import type { UserSessionManager } from "../session/index.ts"
|
|
import type { TRPC } from "../trpc/router.ts"
|
|
|
|
const locationInput = type({
|
|
lat: "number",
|
|
lng: "number",
|
|
accuracy: "number",
|
|
timestamp: "Date",
|
|
})
|
|
|
|
export function createLocationRouter(
|
|
t: TRPC,
|
|
{ sessionManager }: { sessionManager: UserSessionManager },
|
|
) {
|
|
return t.router({
|
|
update: t.procedure.input(locationInput).mutation(async ({ input, ctx }) => {
|
|
const session = sessionManager.getOrCreate(ctx.user.id)
|
|
await session.engine.executeAction("aris.location", "update-location", {
|
|
lat: input.lat,
|
|
lng: input.lng,
|
|
accuracy: input.accuracy,
|
|
timestamp: input.timestamp,
|
|
})
|
|
}),
|
|
})
|
|
}
|