2026-02-18 00:41:20 +00:00
|
|
|
import { LocationSource } from "@aris/source-location"
|
2026-01-25 14:54:08 +00:00
|
|
|
import { Hono } from "hono"
|
|
|
|
|
|
2026-01-25 16:21:00 +00:00
|
|
|
import { registerAuthHandlers } from "./auth/http.ts"
|
2026-02-24 22:30:13 +00:00
|
|
|
import { requireSession } from "./auth/session-middleware.ts"
|
|
|
|
|
import { registerFeedHttpHandlers } from "./feed/http.ts"
|
2026-02-22 20:59:19 +00:00
|
|
|
import { registerLocationHttpHandlers } from "./location/http.ts"
|
2026-02-18 00:41:20 +00:00
|
|
|
import { UserSessionManager } from "./session/index.ts"
|
|
|
|
|
import { WeatherSourceProvider } from "./weather/provider.ts"
|
2026-01-25 16:21:00 +00:00
|
|
|
|
2026-01-25 22:47:53 +00:00
|
|
|
function main() {
|
2026-02-18 00:41:20 +00:00
|
|
|
const sessionManager = new UserSessionManager([
|
|
|
|
|
() => 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!,
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
])
|
|
|
|
|
|
2026-01-25 22:47:53 +00:00
|
|
|
const app = new Hono()
|
2026-01-25 16:21:00 +00:00
|
|
|
|
2026-01-25 22:47:53 +00:00
|
|
|
app.get("/health", (c) => c.json({ status: "ok" }))
|
|
|
|
|
|
|
|
|
|
registerAuthHandlers(app)
|
2026-02-24 22:30:13 +00:00
|
|
|
registerFeedHttpHandlers(app, { sessionManager, authSessionMiddleware: requireSession })
|
2026-02-22 20:59:19 +00:00
|
|
|
registerLocationHttpHandlers(app, { sessionManager })
|
2026-01-25 22:47:53 +00:00
|
|
|
|
|
|
|
|
return app
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const app = main()
|
2026-01-25 22:19:05 +00:00
|
|
|
|
2026-01-25 14:54:08 +00:00
|
|
|
export default {
|
|
|
|
|
port: 3000,
|
|
|
|
|
fetch: app.fetch,
|
|
|
|
|
}
|