Files
Kordant/web/src/server/api/routers/hometitle.ts
Michael Freno a3fee924d8 feat(hometitle): add Backend Router — HomeTitle (Property Monitoring)
- Add hometitle schema (Valibot input schemas)
- Add change detector (fuzzy matching, severity, change detection)
- Add scanner module (geocoding, county records placeholder)
- Add hometitle service (property CRUD, scan, alert pipeline)
- Add hometitle router (7 tRPC procedures)
- Wire into api root
- Add alert type 'property_change' to enum
- Write unit tests (10 tests, all passing)
2026-05-25 16:38:34 -04:00

54 lines
1.6 KiB
TypeScript

import { wrap } from "@typeschema/valibot";
import { createTRPCRouter, protectedProcedure } from "../utils";
import {
AddPropertySchema,
RemovePropertySchema,
GetSnapshotsSchema,
GetChangesSchema,
RunScanSchema,
} from "../schemas/hometitle";
import * as hometitleService from "~/server/services/hometitle.service";
export const hometitleRouter = createTRPCRouter({
getProperties: protectedProcedure.query(async ({ ctx }) => {
return hometitleService.getProperties(ctx.user.id);
}),
addProperty: protectedProcedure
.input(wrap(AddPropertySchema))
.mutation(async ({ ctx, input }) => {
return hometitleService.addProperty(ctx.user.id, input.address, input.parcelId, input.ownerName);
}),
removeProperty: protectedProcedure
.input(wrap(RemovePropertySchema))
.mutation(async ({ ctx, input }) => {
return hometitleService.removeProperty(ctx.user.id, input.propertyId);
}),
getSnapshots: protectedProcedure
.input(wrap(GetSnapshotsSchema))
.query(async ({ ctx, input }) => {
return hometitleService.getSnapshots(ctx.user.id, input.propertyId);
}),
getChanges: protectedProcedure
.input(wrap(GetChangesSchema))
.query(async ({ ctx, input }) => {
return hometitleService.getChanges(ctx.user.id, input.propertyId, {
severity: input.severity,
changeType: input.changeType,
});
}),
runScan: protectedProcedure
.input(wrap(RunScanSchema))
.mutation(async ({ ctx }) => {
return hometitleService.runScan(ctx.user.id);
}),
getAlerts: protectedProcedure.query(async ({ ctx }) => {
return hometitleService.getAlerts(ctx.user.id);
}),
});