fix: make /swaps pass eslint (#665)

This commit is contained in:
Luca Pizzini
2021-10-25 19:52:26 +02:00
committed by GitHub
parent 40ad748cc3
commit 623d5f2b6d
4 changed files with 19 additions and 30 deletions

View File

@@ -42,7 +42,6 @@
/packages/medusa/src/api/routes/admin/shipping-options
/packages/medusa/src/api/routes/admin/shipping-profiles
/packages/medusa/src/api/routes/admin/store
/packages/medusa/src/api/routes/admin/swaps
/packages/medusa/src/api/routes/admin/users

View File

@@ -22,16 +22,12 @@ import { defaultFields, defaultRelations } from "./"
export default async (req, res) => {
const { id } = req.params
try {
const swapService = req.scope.resolve("swapService")
const swapService = req.scope.resolve("swapService")
const swap = await swapService.retrieve(id, {
select: defaultFields,
relations: defaultRelations,
})
const swap = await swapService.retrieve(id, {
select: defaultFields,
relations: defaultRelations,
})
res.json({ swap })
} catch (error) {
throw error
}
res.json({ swap })
}

View File

@@ -3,7 +3,7 @@ import middlewares from "../../../middlewares"
const route = Router()
export default app => {
export default (app) => {
app.use("/swaps", route)
/**

View File

@@ -1,5 +1,3 @@
import _ from "lodash"
/**
* @oas [get] /swaps
* operationId: "GetSwaps"
@@ -20,24 +18,20 @@ import _ from "lodash"
* $ref: "#/components/schemas/swap"
*/
export default async (req, res) => {
try {
const swapService = req.scope.resolve("swapService")
const swapService = req.scope.resolve("swapService")
const limit = parseInt(req.query.limit) || 50
const offset = parseInt(req.query.offset) || 0
const limit = parseInt(req.query.limit) || 50
const offset = parseInt(req.query.offset) || 0
const selector = {}
const selector = {}
const listConfig = {
skip: offset,
take: limit,
order: { created_at: "DESC" },
}
const swaps = await swapService.list(selector, { ...listConfig })
res.json({ swaps, count: swaps.length, offset, limit })
} catch (error) {
throw error
const listConfig = {
skip: offset,
take: limit,
order: { created_at: "DESC" },
}
const swaps = await swapService.list(selector, { ...listConfig })
res.json({ swaps, count: swaps.length, offset, limit })
}