mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 09:01:19 +00:00
* feat(backend): add DB persistence layer Replace raw pg Pool with Drizzle ORM backed by Bun.sql. Add per-user source configuration table (user_sources). Migrate Better Auth to drizzle-adapter. Add AES-256-GCM credential encryption. Co-authored-by: Ona <no-reply@ona.com> * fix(backend): set updatedAt explicitly in all mutations onConflictDoUpdate bypasses Drizzle's $onUpdate hook. Set updatedAt explicitly in all mutation methods. Co-authored-by: Ona <no-reply@ona.com> * fix(backend): add composite index on user_sources Add (user_id, enabled) index for the enabled() query path. Co-authored-by: Ona <no-reply@ona.com> --------- Co-authored-by: Ona <no-reply@ona.com>
26 lines
709 B
TypeScript
26 lines
709 B
TypeScript
import { LocationSource } from "@aelis/source-location"
|
|
|
|
import type { Database } from "../db/index.ts"
|
|
import type { FeedSourceProvider } from "../session/feed-source-provider.ts"
|
|
|
|
import { SourceDisabledError } from "../sources/errors.ts"
|
|
import { sources } from "../sources/user-sources.ts"
|
|
|
|
export class LocationSourceProvider implements FeedSourceProvider {
|
|
private readonly db: Database
|
|
|
|
constructor(db: Database) {
|
|
this.db = db
|
|
}
|
|
|
|
async feedSourceForUser(userId: string): Promise<LocationSource> {
|
|
const row = await sources(this.db, userId).find("aelis.location")
|
|
|
|
if (!row || !row.enabled) {
|
|
throw new SourceDisabledError("aelis.location", userId)
|
|
}
|
|
|
|
return new LocationSource()
|
|
}
|
|
}
|