fix: make packages/medusa/src/api/routes/admin/notes pass eslint (#690)

This commit is contained in:
Asian Cat
2021-10-31 14:04:47 +05:30
committed by GitHub
parent d9ee127284
commit f01166272d
7 changed files with 32 additions and 53 deletions

View File

@@ -23,7 +23,6 @@
/packages/medusa/src/loaders/subscribers.js
/packages/medusa/src/api/routes/admin/auth
/packages/medusa/src/api/routes/admin/collections
/packages/medusa/src/api/routes/admin/notes
/packages/medusa/src/api/routes/store/carts
/packages/medusa/src/api/routes/store/return-reasons
/packages/medusa/src/api/routes/store/returns

View File

@@ -46,18 +46,14 @@ export default async (req, res) => {
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
}
try {
const noteService = req.scope.resolve("noteService")
const noteService = req.scope.resolve("noteService")
const result = await noteService.create({
resource_id: value.resource_id,
resource_type: value.resource_type,
value: value.value,
author_id: userId,
})
const result = await noteService.create({
resource_id: value.resource_id,
resource_type: value.resource_type,
value: value.value,
author_id: userId,
})
res.status(200).json({ note: result })
} catch (err) {
throw err
}
res.status(200).json({ note: result })
}

View File

@@ -24,12 +24,8 @@
export default async (req, res) => {
const { id } = req.params
try {
const noteService = req.scope.resolve("noteService")
await noteService.delete(id)
const noteService = req.scope.resolve("noteService")
await noteService.delete(id)
res.status(200).json({ id, deleted: true })
} catch (err) {
throw err
}
res.status(200).json({ id, deleted: true })
}

View File

@@ -20,12 +20,8 @@
export default async (req, res) => {
const { id } = req.params
try {
const noteService = req.scope.resolve("noteService")
const note = await noteService.retrieve(id, { relations: ["author"] })
const noteService = req.scope.resolve("noteService")
const note = await noteService.retrieve(id, { relations: ["author"] })
res.status(200).json({ note })
} catch (err) {
throw err
}
res.status(200).json({ note })
}

View File

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

View File

@@ -18,25 +18,21 @@
* $ref: "#/components/schemas/note"
*/
export default async (req, res) => {
try {
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 = {}
if ("resource_id" in req.query) {
selector.resource_id = req.query.resource_id
}
const noteService = req.scope.resolve("noteService")
const notes = await noteService.list(selector, {
take: limit,
skip: offset,
relations: ["author"],
})
res.status(200).json({ notes })
} catch (err) {
throw err
if ("resource_id" in req.query) {
selector.resource_id = req.query.resource_id
}
const noteService = req.scope.resolve("noteService")
const notes = await noteService.list(selector, {
take: limit,
skip: offset,
relations: ["author"],
})
res.status(200).json({ notes })
}

View File

@@ -40,12 +40,8 @@ export default async (req, res) => {
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
}
try {
const noteService = req.scope.resolve("noteService")
const result = await noteService.update(id, value.value)
const noteService = req.scope.resolve("noteService")
const result = await noteService.update(id, value.value)
res.status(200).json({ note: result })
} catch (err) {
throw err
}
res.status(200).json({ note: result })
}