-
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.
feat(customer-order): add customer order function and controllers
- Add a new file `customer-order.function.ts` to handle customer order related requests - Implement `CustomerOrderControllerGet` function in `customer/controllers/order/get.ts` to handle GET requests for retrieving customer order details - Implement `CustomerOrderControllerList` function in `customer/controllers/order/list.ts` to handle GET requests for listing customer orders - Define request and response types for `CustomerOrderControllerGet` and `CustomerOrderControllerList` - Update `order.schema.ts` to remove unused schemas and properties - Update `order.types.ts` to remove unused types and properties
- Loading branch information
1 parent
810ebb7
commit 136cad0
Showing
5 changed files
with
71 additions
and
123 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,20 @@ | ||
import "module-alias/register"; | ||
|
||
import { app } from "@azure/functions"; | ||
|
||
import { CustomerOrderControllerGet } from "./customer/controllers/order/get"; | ||
import { CustomerOrderControllerList } from "./customer/controllers/order/list"; | ||
|
||
app.http("customerOrderGet", { | ||
methods: ["GET"], | ||
authLevel: "anonymous", | ||
route: "customer/{customerId?}/lineItemId/{lineItemId?}", | ||
handler: CustomerOrderControllerGet, | ||
}); | ||
|
||
app.http("customerOrderList", { | ||
methods: ["GET"], | ||
authLevel: "anonymous", | ||
route: "customer/{customerId?}/orders/{year?}/{month?}", | ||
handler: CustomerOrderControllerList, | ||
}); |
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,24 @@ | ||
import { z } from "zod"; | ||
import { _ } from "~/library/handler"; | ||
import { NumberOrStringType } from "~/library/zod"; | ||
import { CustomerOrderServiceGet } from "../../services/order/get"; | ||
|
||
export type CustomerOrderControllerGetRequest = { | ||
query: z.infer<typeof CustomerOrderControllerGetSchema>; | ||
}; | ||
|
||
export const CustomerOrderControllerGetSchema = z.object({ | ||
customerId: NumberOrStringType, | ||
lineItemId: NumberOrStringType, | ||
}); | ||
|
||
export type CustomerOrderControllerGetResponse = Awaited< | ||
ReturnType<typeof CustomerOrderServiceGet> | ||
>; | ||
|
||
export const CustomerOrderControllerGet = _( | ||
async ({ query }: CustomerOrderControllerGetRequest) => { | ||
const validateData = CustomerOrderControllerGetSchema.parse(query); | ||
return CustomerOrderServiceGet(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { _ } from "~/library/handler"; | ||
|
||
import { z } from "zod"; | ||
import { NumberOrStringType } from "~/library/zod"; | ||
import { CustomerOrderServiceList } from "../../services/order/list"; | ||
|
||
export type CustomerOrderControllerListRequest = { | ||
query: z.infer<typeof CustomerOrderControllerListSchema>; | ||
}; | ||
|
||
export const CustomerOrderControllerListSchema = z.object({ | ||
customerId: NumberOrStringType, | ||
year: NumberOrStringType, | ||
month: NumberOrStringType, | ||
}); | ||
|
||
export type CustomerOrderControllerListResponse = Awaited< | ||
ReturnType<typeof CustomerOrderServiceList> | ||
>; | ||
|
||
export const CustomerOrderControllerList = _( | ||
async ({ query }: CustomerOrderControllerListRequest) => { | ||
const validateData = CustomerOrderControllerListSchema.parse(query); | ||
return CustomerOrderServiceList(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