-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor payout log pagination in customer module
• Implement new customer-payout-log.function.ts for payout log pagination • Create CustomerPayoutLogControllerPaginate with schema and handler • Fix incorrect import in payout-log/paginate.spec.ts • Update CustomerPayoutLogServicePaginate to include type enhancements and correct aggregation logic
- Loading branch information
1 parent
8a05818
commit a34d045
Showing
4 changed files
with
64 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import "module-alias/register"; | ||
|
||
import { app } from "@azure/functions"; | ||
|
||
import { CustomerPayoutLogControllerPaginate } from "./customer/controllers/payout-log/paginate"; | ||
|
||
app.http("customerPayoutLogPaginate", { | ||
methods: ["GET"], | ||
authLevel: "anonymous", | ||
route: "customer/{customerId?}/payout-log/{payoutId}", | ||
handler: CustomerPayoutLogControllerPaginate, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { _ } from "~/library/handler"; | ||
|
||
import { z } from "zod"; | ||
import { NumberOrStringType, ObjectIdType } from "~/library/zod"; | ||
import { CustomerPayoutLogServicePaginate } from "../../services/payout-log/paginate"; | ||
|
||
export type CustomerPayoutLogControllerPaginateRequest = { | ||
query: z.infer<typeof CustomerPayoutLogControllerPaginateSchema>; | ||
}; | ||
|
||
enum SortOrder { | ||
ASC = "asc", | ||
DESC = "desc", | ||
} | ||
|
||
export const CustomerPayoutLogControllerPaginateSchema = z.object({ | ||
page: NumberOrStringType, | ||
limit: NumberOrStringType.optional(), | ||
sortOrder: z.nativeEnum(SortOrder).optional(), | ||
customerId: NumberOrStringType, | ||
payoutId: ObjectIdType, | ||
}); | ||
|
||
export type CustomerPayoutLogControllerPaginateResponse = Awaited< | ||
ReturnType<typeof CustomerPayoutLogServicePaginate> | ||
>; | ||
|
||
export const CustomerPayoutLogControllerPaginate = _( | ||
async ({ query }: CustomerPayoutLogControllerPaginateRequest) => { | ||
const validateData = CustomerPayoutLogControllerPaginateSchema.parse(query); | ||
return CustomerPayoutLogServicePaginate(validateData); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters