mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 00:51:20 +00:00
Use mockAuthSessionMiddleware with a fully populated dev user when NODE_ENV is not production. Auth handlers are only registered in production. Co-authored-by: Ona <no-reply@ona.com>
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import { LocationSource } from "@aelis/source-location"
|
|
import { Hono } from "hono"
|
|
|
|
import { registerAuthHandlers } from "./auth/http.ts"
|
|
import { mockAuthSessionMiddleware, requireSession } from "./auth/session-middleware.ts"
|
|
import { createFeedEnhancer } from "./enhancement/enhance-feed.ts"
|
|
import { createLlmClient } from "./enhancement/llm-client.ts"
|
|
import { registerFeedHttpHandlers } from "./feed/http.ts"
|
|
import { registerLocationHttpHandlers } from "./location/http.ts"
|
|
import { UserSessionManager } from "./session/index.ts"
|
|
import { WeatherSourceProvider } from "./weather/provider.ts"
|
|
|
|
function main() {
|
|
const openrouterApiKey = process.env.OPENROUTER_API_KEY
|
|
const feedEnhancer = openrouterApiKey
|
|
? createFeedEnhancer({
|
|
client: createLlmClient({
|
|
apiKey: openrouterApiKey,
|
|
model: process.env.OPENROUTER_MODEL || undefined,
|
|
}),
|
|
})
|
|
: null
|
|
if (!feedEnhancer) {
|
|
console.warn("[enhancement] OPENROUTER_API_KEY not set — feed enhancement disabled")
|
|
}
|
|
|
|
const sessionManager = new UserSessionManager({
|
|
providers: [
|
|
() => new LocationSource(),
|
|
new WeatherSourceProvider({
|
|
credentials: {
|
|
privateKey: process.env.WEATHERKIT_PRIVATE_KEY!,
|
|
keyId: process.env.WEATHERKIT_KEY_ID!,
|
|
teamId: process.env.WEATHERKIT_TEAM_ID!,
|
|
serviceId: process.env.WEATHERKIT_SERVICE_ID!,
|
|
},
|
|
}),
|
|
],
|
|
feedEnhancer,
|
|
})
|
|
|
|
const app = new Hono()
|
|
|
|
app.get("/health", (c) => c.json({ status: "ok" }))
|
|
|
|
const isDev = process.env.NODE_ENV !== "production"
|
|
const authSessionMiddleware = isDev ? mockAuthSessionMiddleware("dev-user") : requireSession
|
|
|
|
if (!isDev) {
|
|
registerAuthHandlers(app)
|
|
}
|
|
|
|
registerFeedHttpHandlers(app, {
|
|
sessionManager,
|
|
authSessionMiddleware,
|
|
})
|
|
registerLocationHttpHandlers(app, { sessionManager })
|
|
|
|
return app
|
|
}
|
|
|
|
const app = main()
|
|
|
|
export default {
|
|
port: 3000,
|
|
fetch: app.fetch,
|
|
}
|