fix: make packages/medusa/src/api/routes/admin/auth and 3 others pass eslint (#666)
This commit is contained in:
@@ -10,7 +10,6 @@
|
|||||||
/packages/medusa/src/subscribers/notification.js
|
/packages/medusa/src/subscribers/notification.js
|
||||||
/packages/medusa/src/subscribers/order.js
|
/packages/medusa/src/subscribers/order.js
|
||||||
/packages/medusa/src/subscribers/product.js
|
/packages/medusa/src/subscribers/product.js
|
||||||
|
|
||||||
/packages/medusa/src/loaders/api.js
|
/packages/medusa/src/loaders/api.js
|
||||||
/packages/medusa/src/loaders/database.js
|
/packages/medusa/src/loaders/database.js
|
||||||
/packages/medusa/src/loaders/defaults.js
|
/packages/medusa/src/loaders/defaults.js
|
||||||
@@ -24,33 +23,24 @@
|
|||||||
/packages/medusa/src/loaders/repositories.js
|
/packages/medusa/src/loaders/repositories.js
|
||||||
/packages/medusa/src/loaders/services.js
|
/packages/medusa/src/loaders/services.js
|
||||||
/packages/medusa/src/loaders/subscribers.js
|
/packages/medusa/src/loaders/subscribers.js
|
||||||
|
|
||||||
/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/customers
|
||||||
/packages/medusa/src/api/routes/admin/discounts
|
/packages/medusa/src/api/routes/admin/discounts
|
||||||
/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/notifications
|
/packages/medusa/src/api/routes/admin/notifications
|
||||||
/packages/medusa/src/api/routes/admin/orders
|
/packages/medusa/src/api/routes/admin/orders
|
||||||
/packages/medusa/src/api/routes/admin/regions
|
|
||||||
/packages/medusa/src/api/routes/admin/return-reasons
|
/packages/medusa/src/api/routes/admin/return-reasons
|
||||||
/packages/medusa/src/api/routes/admin/returns
|
/packages/medusa/src/api/routes/admin/returns
|
||||||
/packages/medusa/src/api/routes/admin/shipping-options
|
/packages/medusa/src/api/routes/admin/shipping-options
|
||||||
/packages/medusa/src/api/routes/admin/shipping-profiles
|
/packages/medusa/src/api/routes/admin/shipping-profiles
|
||||||
/packages/medusa/src/api/routes/admin/store
|
/packages/medusa/src/api/routes/admin/store
|
||||||
/packages/medusa/src/api/routes/admin/users
|
/packages/medusa/src/api/routes/admin/users
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/packages/medusa/src/api/routes/store/carts
|
/packages/medusa/src/api/routes/store/carts
|
||||||
|
|
||||||
/packages/medusa/src/api/routes/store/regions
|
|
||||||
/packages/medusa/src/api/routes/store/return-reasons
|
/packages/medusa/src/api/routes/store/return-reasons
|
||||||
/packages/medusa/src/api/routes/store/returns
|
/packages/medusa/src/api/routes/store/returns
|
||||||
|
|
||||||
/packages/medusa/src/api/routes/store/swaps
|
/packages/medusa/src/api/routes/store/swaps
|
||||||
|
|
||||||
# END OF FILES TODO
|
# END OF FILES TODO
|
||||||
@@ -61,7 +51,6 @@
|
|||||||
/packages/medusa/src/helpers
|
/packages/medusa/src/helpers
|
||||||
/packages/medusa/src/migrations
|
/packages/medusa/src/migrations
|
||||||
/packages/medusa/src/utils
|
/packages/medusa/src/utils
|
||||||
|
|
||||||
/integration-tests
|
/integration-tests
|
||||||
/docs
|
/docs
|
||||||
/docs-util
|
/docs-util
|
||||||
|
|||||||
@@ -39,7 +39,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 regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
await regionService.addCountry(region_id, value.country_code)
|
await regionService.addCountry(region_id, value.country_code)
|
||||||
|
|
||||||
@@ -49,7 +48,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ region })
|
res.status(200).json({ region })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,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 regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
await regionService.addFulfillmentProvider(region_id, value.provider_id)
|
await regionService.addFulfillmentProvider(region_id, value.provider_id)
|
||||||
|
|
||||||
@@ -48,7 +47,4 @@ export default async (req, res) => {
|
|||||||
relations: defaultRelations,
|
relations: defaultRelations,
|
||||||
})
|
})
|
||||||
res.status(200).json({ region: data })
|
res.status(200).json({ region: data })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,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 regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
await regionService.addPaymentProvider(region_id, value.provider_id)
|
await regionService.addPaymentProvider(region_id, value.provider_id)
|
||||||
|
|
||||||
@@ -48,7 +47,4 @@ export default async (req, res) => {
|
|||||||
relations: defaultRelations,
|
relations: defaultRelations,
|
||||||
})
|
})
|
||||||
res.status(200).json({ region: data })
|
res.status(200).json({ region: data })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,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 regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
const result = await regionService.create(value)
|
const result = await regionService.create(value)
|
||||||
|
|
||||||
@@ -76,7 +75,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ region })
|
res.status(200).json({ region })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import { defaultRelations, defaultFields } from "./"
|
|||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { id, key } = req.params
|
const { id, key } = req.params
|
||||||
|
|
||||||
try {
|
|
||||||
const regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
await regionService.deleteMetadata(id, key)
|
await regionService.deleteMetadata(id, key)
|
||||||
|
|
||||||
@@ -33,7 +32,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ region })
|
res.status(200).json({ region })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { MedusaError, Validator } from "medusa-core-utils"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [delete] /regions/{id}
|
* @oas [delete] /regions/{id}
|
||||||
* operationId: "DeleteRegionsRegion"
|
* operationId: "DeleteRegionsRegion"
|
||||||
@@ -27,7 +25,6 @@ import { MedusaError, Validator } from "medusa-core-utils"
|
|||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { region_id } = req.params
|
const { region_id } = req.params
|
||||||
try {
|
|
||||||
const regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
await regionService.delete(region_id)
|
await regionService.delete(region_id)
|
||||||
|
|
||||||
@@ -36,7 +33,4 @@ export default async (req, res) => {
|
|||||||
object: "region",
|
object: "region",
|
||||||
deleted: true,
|
deleted: true,
|
||||||
})
|
})
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { region_id } = req.params
|
const { region_id } = req.params
|
||||||
|
|
||||||
try {
|
|
||||||
const fulfillmentProviderService = req.scope.resolve(
|
const fulfillmentProviderService = req.scope.resolve(
|
||||||
"fulfillmentProviderService"
|
"fulfillmentProviderService"
|
||||||
)
|
)
|
||||||
@@ -31,7 +30,7 @@ export default async (req, res) => {
|
|||||||
relations: ["fulfillment_providers"],
|
relations: ["fulfillment_providers"],
|
||||||
})
|
})
|
||||||
|
|
||||||
const fpsIds = region.fulfillment_providers.map(fp => fp.id) || []
|
const fpsIds = region.fulfillment_providers.map((fp) => fp.id) || []
|
||||||
|
|
||||||
const options = await fulfillmentProviderService.listFulfillmentOptions(
|
const options = await fulfillmentProviderService.listFulfillmentOptions(
|
||||||
fpsIds
|
fpsIds
|
||||||
@@ -40,7 +39,4 @@ export default async (req, res) => {
|
|||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
fulfillment_options: options,
|
fulfillment_options: options,
|
||||||
})
|
})
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { MedusaError, Validator } from "medusa-core-utils"
|
|
||||||
import { defaultRelations, defaultFields } from "./"
|
import { defaultRelations, defaultFields } from "./"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,7 +21,6 @@ import { defaultRelations, defaultFields } from "./"
|
|||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { region_id } = req.params
|
const { region_id } = req.params
|
||||||
try {
|
|
||||||
const regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
const data = await regionService.retrieve(region_id, {
|
const data = await regionService.retrieve(region_id, {
|
||||||
select: defaultFields,
|
select: defaultFields,
|
||||||
@@ -30,7 +28,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ region: data })
|
res.status(200).json({ region: data })
|
||||||
} 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("/regions", route)
|
app.use("/regions", route)
|
||||||
|
|
||||||
route.get("/", middlewares.wrap(require("./list-regions").default))
|
route.get("/", middlewares.wrap(require("./list-regions").default))
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import { defaultFields, defaultRelations } from "./"
|
|||||||
* $ref: "#/components/schemas/region"
|
* $ref: "#/components/schemas/region"
|
||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
try {
|
|
||||||
const regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
|
|
||||||
const limit = parseInt(req.query.limit) || 50
|
const limit = parseInt(req.query.limit) || 50
|
||||||
@@ -35,10 +34,7 @@ export default async (req, res) => {
|
|||||||
take: limit,
|
take: limit,
|
||||||
}
|
}
|
||||||
|
|
||||||
let regions = await regionService.list(selector, listConfig)
|
const regions = await regionService.list(selector, listConfig)
|
||||||
|
|
||||||
res.json({ regions, count: regions.length, offset, limit })
|
res.json({ regions, count: regions.length, offset, limit })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { MedusaError, Validator } from "medusa-core-utils"
|
|
||||||
import { defaultRelations, defaultFields } from "./"
|
import { defaultRelations, defaultFields } from "./"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +22,6 @@ import { defaultRelations, defaultFields } from "./"
|
|||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { region_id, country_code } = req.params
|
const { region_id, country_code } = req.params
|
||||||
try {
|
|
||||||
const regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
await regionService.removeCountry(region_id, country_code)
|
await regionService.removeCountry(region_id, country_code)
|
||||||
|
|
||||||
@@ -33,7 +31,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.json({ region })
|
res.json({ region })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { MedusaError, Validator } from "medusa-core-utils"
|
|
||||||
import { defaultRelations, defaultFields } from "./"
|
import { defaultRelations, defaultFields } from "./"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +22,6 @@ import { defaultRelations, defaultFields } from "./"
|
|||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { region_id, provider_id } = req.params
|
const { region_id, provider_id } = req.params
|
||||||
try {
|
|
||||||
const regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
|
|
||||||
await regionService.removeFulfillmentProvider(region_id, provider_id)
|
await regionService.removeFulfillmentProvider(region_id, provider_id)
|
||||||
@@ -34,7 +32,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.json({ region })
|
res.json({ region })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { MedusaError, Validator } from "medusa-core-utils"
|
|
||||||
import { defaultRelations, defaultFields } from "./"
|
import { defaultRelations, defaultFields } from "./"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +22,6 @@ import { defaultRelations, defaultFields } from "./"
|
|||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { region_id, provider_id } = req.params
|
const { region_id, provider_id } = req.params
|
||||||
try {
|
|
||||||
const regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
await regionService.removePaymentProvider(region_id, provider_id)
|
await regionService.removePaymentProvider(region_id, provider_id)
|
||||||
|
|
||||||
@@ -33,7 +31,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.json({ region })
|
res.json({ region })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { MedusaError, Validator } from "medusa-core-utils"
|
import { MedusaError, Validator } from "medusa-core-utils"
|
||||||
|
import { defaultFields, defaultRelations } from "."
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
@@ -13,17 +14,13 @@ 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 regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
await regionService.setMetadata(id, value.key, value.value)
|
await regionService.setMetadata(id, value.key, value.value)
|
||||||
|
|
||||||
const region = await regionService.retrieve(region_id, {
|
const region = await regionService.retrieve(id, {
|
||||||
select: defaultFields,
|
select: defaultFields,
|
||||||
relations: defaultRelations,
|
relations: defaultRelations,
|
||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ region })
|
res.status(200).json({ region })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,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 regionService = req.scope.resolve("regionService")
|
const regionService = req.scope.resolve("regionService")
|
||||||
await regionService.update(region_id, value)
|
await regionService.update(region_id, value)
|
||||||
const region = await regionService.retrieve(region_id, {
|
const region = await regionService.retrieve(region_id, {
|
||||||
@@ -79,7 +78,4 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ region })
|
res.status(200).json({ region })
|
||||||
} catch (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user