chore: Make packages/medusa/src/api/routes/admin/customers pass linting (#681)

This commit is contained in:
Luca Pizzini authored and GitHub committed 2021-10-26 19:55:08 +02:00
1 parent 68c2a4fe3a
commit 748270a75d
6 files changed
+3 -21

No files matched your search

-1
View File
@@ -26,7 +26,6 @@
/packages/medusa/src/api/routes/admin/apps /packages/medusa/src/api/routes/admin/apps
/packages/medusa/src/api/routes/admin/auth /packages/medusa/src/api/routes/admin/auth
/packages/medusa/src/api/routes/admin/collections /packages/medusa/src/api/routes/admin/collections
/packages/medusa/src/api/routes/admin/customers
/packages/medusa/src/api/routes/admin/draft-orders /packages/medusa/src/api/routes/admin/draft-orders
/packages/medusa/src/api/routes/admin/notes /packages/medusa/src/api/routes/admin/notes
/packages/medusa/src/api/routes/admin/orders /packages/medusa/src/api/routes/admin/orders
@@ -24,9 +24,7 @@ import { Validator, MedusaError } from "medusa-core-utils"
*/ */
export default async (req, res) => { export default async (req, res) => {
const schema = Validator.object().keys({ const schema = Validator.object().keys({
email: Validator.string() email: Validator.string().email().required(),
.email()
.required(),
first_name: Validator.string().required(), first_name: Validator.string().required(),
last_name: Validator.string().required(), last_name: Validator.string().required(),
password: Validator.string().required(), password: Validator.string().required(),
@@ -37,11 +35,8 @@ export default async (req, res) => {
if (error) { if (error) {
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.create(value) const customer = await customerService.create(value)
res.status(201).json({ customer }) res.status(201).json({ customer })
} catch (err) {
throw err
}
} }
@@ -19,14 +19,10 @@
*/ */
export default async (req, res) => { export default async (req, res) => {
const { id } = req.params const { id } = req.params
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: ["orders", "shipping_addresses"], relations: ["orders", "shipping_addresses"],
}) })
res.json({ customer }) res.json({ customer })
} 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("/customers", route) app.use("/customers", route)
route.get("/", middlewares.wrap(require("./list-customers").default)) route.get("/", middlewares.wrap(require("./list-customers").default))
@@ -16,7 +16,6 @@
* $ref: "#/components/schemas/customer" * $ref: "#/components/schemas/customer"
*/ */
export default async (req, res) => { export default async (req, res) => {
try {
const customerService = req.scope.resolve("customerService") const customerService = req.scope.resolve("customerService")
const limit = parseInt(req.query.limit) || 50 const limit = parseInt(req.query.limit) || 50
@@ -45,7 +44,4 @@ export default async (req, res) => {
) )
res.json({ customers, count, offset, limit }) res.json({ customers, count, offset, limit })
} catch (error) {
throw error
}
} }
@@ -52,7 +52,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.retrieve(id) let customer = await customerService.retrieve(id)
@@ -70,7 +69,4 @@ export default async (req, res) => {
relations: ["orders"], relations: ["orders"],
}) })
res.status(200).json({ customer }) res.status(200).json({ customer })
} catch (err) {
throw err
}
} }