fix: make /api/routes/admin/gift-cards,routes/store/gift-cards,/routes/store/orders pass linting (#643)
This commit is contained in:
+2
-3
@@ -32,7 +32,7 @@
|
|||||||
/packages/medusa/src/api/routes/admin/customers
|
/packages/medusa/src/api/routes/admin/customers
|
||||||
/packages/medusa/src/api/routes/admin/discounts
|
/packages/medusa/src/api/routes/admin/discounts
|
||||||
/packages/medusa/src/api/routes/admin/draft-orders
|
/packages/medusa/src/api/routes/admin/draft-orders
|
||||||
/packages/medusa/src/api/routes/admin/gift-cards
|
|
||||||
/packages/medusa/src/api/routes/admin/notes
|
/packages/medusa/src/api/routes/admin/notes
|
||||||
/packages/medusa/src/api/routes/admin/notifications
|
/packages/medusa/src/api/routes/admin/notifications
|
||||||
/packages/medusa/src/api/routes/admin/orders
|
/packages/medusa/src/api/routes/admin/orders
|
||||||
@@ -50,9 +50,8 @@
|
|||||||
/packages/medusa/src/api/routes/store/auth
|
/packages/medusa/src/api/routes/store/auth
|
||||||
/packages/medusa/src/api/routes/store/carts
|
/packages/medusa/src/api/routes/store/carts
|
||||||
/packages/medusa/src/api/routes/store/customers
|
/packages/medusa/src/api/routes/store/customers
|
||||||
/packages/medusa/src/api/routes/store/gift-cards
|
|
||||||
/packages/medusa/src/api/routes/store/orders
|
|
||||||
/packages/medusa/src/api/routes/store/products
|
/packages/medusa/src/api/routes/store/products
|
||||||
|
|
||||||
/packages/medusa/src/api/routes/store/regions
|
/packages/medusa/src/api/routes/store/regions
|
||||||
/packages/medusa/src/api/routes/store/return-reasons
|
/packages/medusa/src/api/routes/store/return-reasons
|
||||||
/packages/medusa/src/api/routes/store/returns
|
/packages/medusa/src/api/routes/store/returns
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ import { defaultFields, defaultRelations } from "./"
|
|||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const schema = Validator.object().keys({
|
const schema = Validator.object().keys({
|
||||||
value: Validator.number()
|
value: Validator.number().integer().optional(),
|
||||||
.integer()
|
|
||||||
.optional(),
|
|
||||||
ends_at: Validator.date().optional(),
|
ends_at: Validator.date().optional(),
|
||||||
is_disabled: Validator.boolean().optional(),
|
is_disabled: Validator.boolean().optional(),
|
||||||
region_id: Validator.string().optional(),
|
region_id: Validator.string().optional(),
|
||||||
@@ -57,7 +55,6 @@ export default async (req, res) => {
|
|||||||
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
const giftCardService = req.scope.resolve("giftCardService")
|
const giftCardService = req.scope.resolve("giftCardService")
|
||||||
|
|
||||||
const newly = await giftCardService.create({
|
const newly = await giftCardService.create({
|
||||||
@@ -71,7 +68,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ gift_card: giftCard })
|
res.status(200).json({ gift_card: giftCard })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|
||||||
try {
|
|
||||||
const giftCardService = req.scope.resolve("giftCardService")
|
const giftCardService = req.scope.resolve("giftCardService")
|
||||||
await giftCardService.delete(id)
|
await giftCardService.delete(id)
|
||||||
|
|
||||||
@@ -35,7 +34,4 @@ export default async (req, res) => {
|
|||||||
object: "gift-card",
|
object: "gift-card",
|
||||||
deleted: true,
|
deleted: true,
|
||||||
})
|
})
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import { defaultFields, defaultRelations } from "./"
|
|||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|
||||||
try {
|
|
||||||
const giftCardService = req.scope.resolve("giftCardService")
|
const giftCardService = req.scope.resolve("giftCardService")
|
||||||
const giftCard = await giftCardService.retrieve(id, {
|
const giftCard = await giftCardService.retrieve(id, {
|
||||||
select: defaultFields,
|
select: defaultFields,
|
||||||
@@ -30,7 +29,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ gift_card: giftCard })
|
res.status(200).json({ gift_card: giftCard })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import middlewares from "../../../middlewares"
|
|||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
export default app => {
|
export default (app) => {
|
||||||
app.use("/gift-cards", route)
|
app.use("/gift-cards", route)
|
||||||
|
|
||||||
route.get("/", middlewares.wrap(require("./list-gift-cards").default))
|
route.get("/", middlewares.wrap(require("./list-gift-cards").default))
|
||||||
@@ -33,10 +33,7 @@ export const defaultFields = [
|
|||||||
"metadata",
|
"metadata",
|
||||||
]
|
]
|
||||||
|
|
||||||
export const defaultRelations = [
|
export const defaultRelations = ["region", "order"]
|
||||||
"region",
|
|
||||||
"order",
|
|
||||||
]
|
|
||||||
|
|
||||||
export const allowedFields = [
|
export const allowedFields = [
|
||||||
"id",
|
"id",
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { MedusaError, Validator } from "medusa-core-utils"
|
|
||||||
import { defaultFields, defaultRelations } from "./"
|
import { defaultFields, defaultRelations } from "./"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,7 +20,6 @@ import { defaultFields, defaultRelations } from "./"
|
|||||||
* $ref: "#/components/schemas/gift_card"
|
* $ref: "#/components/schemas/gift_card"
|
||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
try {
|
|
||||||
const limit = parseInt(req.query.limit) || 50
|
const limit = parseInt(req.query.limit) || 50
|
||||||
const offset = parseInt(req.query.offset) || 0
|
const offset = parseInt(req.query.offset) || 0
|
||||||
|
|
||||||
@@ -42,7 +40,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ gift_cards: giftCards })
|
res.status(200).json({ gift_cards: giftCards })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,9 +47,7 @@ export default async (req, res) => {
|
|||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|
||||||
const schema = Validator.object().keys({
|
const schema = Validator.object().keys({
|
||||||
balance: Validator.number()
|
balance: Validator.number().precision(0).optional(),
|
||||||
.precision(0)
|
|
||||||
.optional(),
|
|
||||||
ends_at: Validator.date().optional(),
|
ends_at: Validator.date().optional(),
|
||||||
is_disabled: Validator.boolean().optional(),
|
is_disabled: Validator.boolean().optional(),
|
||||||
region_id: Validator.string().optional(),
|
region_id: Validator.string().optional(),
|
||||||
@@ -61,7 +59,6 @@ export default async (req, res) => {
|
|||||||
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
const giftCardService = req.scope.resolve("giftCardService")
|
const giftCardService = req.scope.resolve("giftCardService")
|
||||||
|
|
||||||
await giftCardService.update(id, value)
|
await giftCardService.update(id, value)
|
||||||
@@ -72,7 +69,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ gift_card: giftCard })
|
res.status(200).json({ gift_card: giftCard })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import { defaultFields, defaultRelations } from "."
|
|||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { cart_id } = req.params
|
const { cart_id } = req.params
|
||||||
|
|
||||||
try {
|
|
||||||
const orderService = req.scope.resolve("orderService")
|
const orderService = req.scope.resolve("orderService")
|
||||||
const order = await orderService.retrieveByCartId(cart_id, {
|
const order = await orderService.retrieveByCartId(cart_id, {
|
||||||
select: defaultFields,
|
select: defaultFields,
|
||||||
@@ -30,7 +29,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.json({ order })
|
res.json({ order })
|
||||||
} catch (error) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user