- Create Valibot schemas for removal request CRUD, scan, and listing filters - Implement broker registry with 48 major data brokers and removal metadata - Build removal engine with automated, form, email, and status tracking support - Add service layer with subscription-scoped operations: create/get/scan/stats/process - Wire removebrokers router into root app router - Write 20 passing unit tests (router + service layer)
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { wrap } from "@typeschema/valibot";
|
|
import { createTRPCRouter, protectedProcedure } from "../utils";
|
|
import {
|
|
CreateRemovalRequestSchema,
|
|
RequestStatusSchema,
|
|
ScanListingsSchema,
|
|
BrokerListingsFilterSchema,
|
|
RemovalRequestsFilterSchema,
|
|
} from "../schemas/removebrokers";
|
|
import * as removebrokersService from "~/server/services/removebrokers.service";
|
|
|
|
export const removebrokersRouter = createTRPCRouter({
|
|
getBrokerRegistry: protectedProcedure.query(async () => {
|
|
return removebrokersService.getBrokerRegistry();
|
|
}),
|
|
|
|
getRemovalRequests: protectedProcedure
|
|
.input(wrap(RemovalRequestsFilterSchema))
|
|
.query(async ({ ctx, input }) => {
|
|
return removebrokersService.getRemovalRequests(ctx.user.id, input);
|
|
}),
|
|
|
|
createRemovalRequest: protectedProcedure
|
|
.input(wrap(CreateRemovalRequestSchema))
|
|
.mutation(async ({ ctx, input }) => {
|
|
return removebrokersService.createRemovalRequest(ctx.user.id, input.brokerId, input.personalInfo);
|
|
}),
|
|
|
|
getRequestStatus: protectedProcedure
|
|
.input(wrap(RequestStatusSchema))
|
|
.query(async ({ ctx, input }) => {
|
|
return removebrokersService.getRequestStatus(ctx.user.id, input.requestId);
|
|
}),
|
|
|
|
getBrokerListings: protectedProcedure
|
|
.input(wrap(BrokerListingsFilterSchema))
|
|
.query(async ({ ctx, input }) => {
|
|
return removebrokersService.getBrokerListings(ctx.user.id, input);
|
|
}),
|
|
|
|
scanForListings: protectedProcedure
|
|
.input(wrap(ScanListingsSchema))
|
|
.mutation(async ({ ctx, input }) => {
|
|
return removebrokersService.scanForListings(ctx.user.id, input.brokerId);
|
|
}),
|
|
|
|
getStats: protectedProcedure.query(async ({ ctx }) => {
|
|
return removebrokersService.getStats(ctx.user.id);
|
|
}),
|
|
});
|