fix(medusa): Add missing scoped transaction on update currency endpoint (#3254)
This commit is contained in:
1 parent
66e7a384e3
commit
10ff72c30a
2 files changed
+14
-1
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): Add missing scoped transaction on update currency endpoint
|
||||||
@@ -4,6 +4,7 @@ import { ExtendedRequest } from "../../../../types/global"
|
|||||||
import { CurrencyService } from "../../../../services"
|
import { CurrencyService } from "../../../../services"
|
||||||
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
||||||
import TaxInclusivePricingFeatureFlag from "../../../../loaders/feature-flags/tax-inclusive-pricing"
|
import TaxInclusivePricingFeatureFlag from "../../../../loaders/feature-flags/tax-inclusive-pricing"
|
||||||
|
import { EntityManager } from "typeorm"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /currencies/{code}
|
* @oas [post] /currencies/{code}
|
||||||
@@ -56,8 +57,15 @@ export default async (req: ExtendedRequest<Currency>, res) => {
|
|||||||
const code = req.params.code as string
|
const code = req.params.code as string
|
||||||
const data = req.validatedBody as AdminPostCurrenciesCurrencyReq
|
const data = req.validatedBody as AdminPostCurrenciesCurrencyReq
|
||||||
const currencyService: CurrencyService = req.scope.resolve("currencyService")
|
const currencyService: CurrencyService = req.scope.resolve("currencyService")
|
||||||
|
const manager: EntityManager = req.scope.resolve("manager")
|
||||||
|
|
||||||
const currency = await currencyService.update(code, data)
|
const currency = await manager.transaction(
|
||||||
|
async (transactionManager) => {
|
||||||
|
return await currencyService
|
||||||
|
.withTransaction(transactionManager)
|
||||||
|
.update(code, data)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
res.json({ currency })
|
res.json({ currency })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user