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

This commit is contained in:
Luca Pizzini
2021-10-26 19:55:08 +02:00
committed by GitHub
parent 68c2a4fe3a
commit 748270a75d
6 changed files with 49 additions and 67 deletions

View File

@@ -26,7 +26,6 @@
/packages/medusa/src/api/routes/admin/apps
/packages/medusa/src/api/routes/admin/auth
/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/notes
/packages/medusa/src/api/routes/admin/orders

View File

@@ -24,9 +24,7 @@ import { Validator, MedusaError } from "medusa-core-utils"
*/
export default async (req, res) => {
const schema = Validator.object().keys({
email: Validator.string()
.email()
.required(),
email: Validator.string().email().required(),
first_name: Validator.string().required(),
last_name: Validator.string().required(),
password: Validator.string().required(),
@@ -37,11 +35,8 @@ export default async (req, res) => {
if (error) {
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
}
try {
const customerService = req.scope.resolve("customerService")
const customer = await customerService.create(value)
res.status(201).json({ customer })
} catch (err) {
throw err
}
}

View File

@@ -19,14 +19,10 @@
*/
export default async (req, res) => {
const { id } = req.params
try {
const customerService = req.scope.resolve("customerService")
const customer = await customerService.retrieve(id, {
relations: ["orders", "shipping_addresses"],
})
res.json({ customer })
} catch (err) {
throw err
}
}

View File

@@ -3,7 +3,7 @@ import middlewares from "../../../middlewares"
const route = Router()
export default app => {
export default (app) => {
app.use("/customers", route)
route.get("/", middlewares.wrap(require("./list-customers").default))

View File

@@ -16,7 +16,6 @@
* $ref: "#/components/schemas/customer"
*/
export default async (req, res) => {
try {
const customerService = req.scope.resolve("customerService")
const limit = parseInt(req.query.limit) || 50
@@ -45,7 +44,4 @@ export default async (req, res) => {
)
res.json({ customers, count, offset, limit })
} catch (error) {
throw error
}
}

View File

@@ -52,7 +52,6 @@ export default async (req, res) => {
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
}
try {
const customerService = req.scope.resolve("customerService")
let customer = await customerService.retrieve(id)
@@ -70,7 +69,4 @@ export default async (req, res) => {
relations: ["orders"],
})
res.status(200).json({ customer })
} catch (err) {
throw err
}
}