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)
This commit is contained in:
53
web/src/server/api/routers/hometitle.ts
Normal file
53
web/src/server/api/routers/hometitle.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
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);
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user