-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathindex.ts
64 lines (55 loc) · 1.67 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { Router } from "express"
import { PricedVariant } from "../../../../types/pricing"
import middlewares from "../../../middlewares"
import { extendRequestParams } from "../../../middlewares/publishable-api-key/extend-request-params"
import { validateSalesChannelParam } from "../../../middlewares/publishable-api-key/validate-sales-channel-param"
import { validateProductVariantSalesChannelAssociation } from "../../../middlewares/publishable-api-key/validate-variant-sales-channel-association"
const route = Router()
export default (app) => {
app.use("/variants", extendRequestParams, validateSalesChannelParam, route)
route.use("/:id", validateProductVariantSalesChannelAssociation)
route.get("/", middlewares.wrap(require("./list-variants").default))
route.get("/:id", middlewares.wrap(require("./get-variant").default))
return app
}
export const defaultStoreVariantRelations = ["prices", "options", "product"]
/**
* @schema StoreVariantsRes
* type: object
* x-expanded-relations:
* field: variant
* relations:
* - prices
* - options
* - product
* required:
* - variant
* properties:
* variant:
* $ref: "#/components/schemas/PricedVariant"
*/
export type StoreVariantsRes = {
variant: PricedVariant
}
/**
* @schema StoreVariantsListRes
* type: object
* x-expanded-relations:
* field: variants
* relations:
* - prices
* - options
* - product
* required:
* - variants
* properties:
* variants:
* type: array
* items:
* $ref: "#/components/schemas/PricedVariant"
*/
export type StoreVariantsListRes = {
variants: PricedVariant[]
}
export * from "./list-variants"
export * from "./get-variant"