fix: /api/routes/store/customers pass linting (#646)
This commit is contained in:
@@ -49,7 +49,6 @@
|
|||||||
|
|
||||||
/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/regions
|
/packages/medusa/src/api/routes/store/regions
|
||||||
/packages/medusa/src/api/routes/store/return-reasons
|
/packages/medusa/src/api/routes/store/return-reasons
|
||||||
|
|||||||
@@ -41,7 +41,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 customerService = req.scope.resolve("customerService")
|
const customerService = req.scope.resolve("customerService")
|
||||||
|
|
||||||
let customer = await customerService.addAddress(id, value.address)
|
let customer = await customerService.addAddress(id, value.address)
|
||||||
@@ -51,7 +50,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ customer })
|
res.status(200).json({ customer })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,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 customerService = req.scope.resolve("customerService")
|
const customerService = req.scope.resolve("customerService")
|
||||||
let customer = await customerService.create(value)
|
let customer = await customerService.create(value)
|
||||||
|
|
||||||
@@ -55,7 +54,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ customer })
|
res.status(200).json({ customer })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,15 +25,11 @@ export default async (req, res) => {
|
|||||||
const { address_id } = req.params
|
const { address_id } = req.params
|
||||||
|
|
||||||
const customerService = req.scope.resolve("customerService")
|
const customerService = req.scope.resolve("customerService")
|
||||||
try {
|
|
||||||
await customerService.removeAddress(id, address_id)
|
await customerService.removeAddress(id, address_id)
|
||||||
customer = await customerService.retrieve(id, {
|
const customer = await customerService.retrieve(id, {
|
||||||
relations: defaultRelations,
|
relations: defaultRelations,
|
||||||
select: defaultFields,
|
select: defaultFields,
|
||||||
})
|
})
|
||||||
|
|
||||||
res.json({ customer })
|
res.json({ customer })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,10 @@ import { defaultRelations, defaultFields } from "./"
|
|||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const id = req.user.customer_id
|
const id = req.user.customer_id
|
||||||
try {
|
|
||||||
const customerService = req.scope.resolve("customerService")
|
const customerService = req.scope.resolve("customerService")
|
||||||
const customer = await customerService.retrieve(id, {
|
const customer = await customerService.retrieve(id, {
|
||||||
relations: defaultRelations,
|
relations: defaultRelations,
|
||||||
select: defaultFields,
|
select: defaultFields,
|
||||||
})
|
})
|
||||||
res.json({ customer })
|
res.json({ customer })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const id = req.user.customer_id
|
const id = req.user.customer_id
|
||||||
try {
|
|
||||||
const storeService = req.scope.resolve("storeService")
|
const storeService = req.scope.resolve("storeService")
|
||||||
const paymentProviderService = req.scope.resolve("paymentProviderService")
|
const paymentProviderService = req.scope.resolve("paymentProviderService")
|
||||||
const customerService = req.scope.resolve("customerService")
|
const customerService = req.scope.resolve("customerService")
|
||||||
@@ -49,7 +48,4 @@ export default async (req, res) => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
res.json({ payment_methods: methods.flat() })
|
res.json({ payment_methods: methods.flat() })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import _ from "lodash"
|
|
||||||
import {
|
import {
|
||||||
defaultRelations,
|
defaultRelations,
|
||||||
defaultFields,
|
defaultFields,
|
||||||
@@ -29,7 +28,7 @@ import {
|
|||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const id = req.user.customer_id
|
const id = req.user.customer_id
|
||||||
try {
|
|
||||||
const orderService = req.scope.resolve("orderService")
|
const orderService = req.scope.resolve("orderService")
|
||||||
|
|
||||||
const selector = {
|
const selector = {
|
||||||
@@ -59,13 +58,7 @@ export default async (req, res) => {
|
|||||||
order: { created_at: "DESC" },
|
order: { created_at: "DESC" },
|
||||||
}
|
}
|
||||||
|
|
||||||
const [orders, count] = await orderService.listAndCount(
|
const [orders, count] = await orderService.listAndCount(selector, listConfig)
|
||||||
selector,
|
|
||||||
listConfig
|
|
||||||
)
|
|
||||||
|
|
||||||
res.json({ orders, count, offset, limit })
|
res.json({ orders, count, offset, limit })
|
||||||
} catch (error) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,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 customerService = req.scope.resolve("customerService")
|
const customerService = req.scope.resolve("customerService")
|
||||||
const customer = await customerService.retrieveByEmail(value.email)
|
const customer = await customerService.retrieveByEmail(value.email)
|
||||||
|
|
||||||
@@ -29,7 +28,4 @@ export default async (req, res) => {
|
|||||||
await customerService.generateResetPasswordToken(customer.id)
|
await customerService.generateResetPasswordToken(customer.id)
|
||||||
|
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
} catch (error) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export default async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const customerService = req.scope.resolve("customerService")
|
const customerService = req.scope.resolve("customerService")
|
||||||
try {
|
|
||||||
let customer = await customerService.updateAddress(
|
let customer = await customerService.updateAddress(
|
||||||
id,
|
id,
|
||||||
address_id,
|
address_id,
|
||||||
@@ -56,7 +56,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.json({ customer })
|
res.json({ customer })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { optional } from "joi"
|
|
||||||
import { Validator, MedusaError } from "medusa-core-utils"
|
import { Validator, MedusaError } from "medusa-core-utils"
|
||||||
import { defaultRelations, defaultFields } from "./"
|
import { defaultRelations, defaultFields } from "./"
|
||||||
|
|
||||||
@@ -64,7 +63,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 customerService = req.scope.resolve("customerService")
|
const customerService = req.scope.resolve("customerService")
|
||||||
await customerService.update(id, value)
|
await customerService.update(id, value)
|
||||||
|
|
||||||
@@ -74,7 +72,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ customer })
|
res.status(200).json({ customer })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user