Replaces MongoDB support with PostgreSQL (#151)

- All schemas have been rewritten to a relational model
- All services have been rewritten to accommodate the new data model
- Adds idempotency keys to core endpoints allowing you to retry requests with no additional side effects
- Adds staged jobs to avoid putting jobs in the queue when transactions abort
- Adds atomic transactions to all methods with access to the data layer

Co-authored-by: Oliver Windall Juhl <oliver@mrbltech.com>
This commit is contained in:
Sebastian RindomandOliver Windall Juhl committed 2021-01-26 10:26:14 +01:00
1 parent 5f819486fc
commit f1baca3cbd
499 files changed
+25909 -16128

No files matched your search

+5 -1
View File
@@ -5,5 +5,9 @@ node_modules
/*.js
!index.js
yarn.lock
src
.gitignore
.eslintrc
.babelrc
.prettierrc
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-ip-lookup",
"version": "1.0.11",
"version": "1.0.12-alpha.787+0646bd3",
"description": "IP lookup middleware for Medusa core",
"main": "dist/index.js",
"repository": {
@@ -35,5 +35,5 @@
"axios": "^0.20.0",
"mongoose": "^5.8.0"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
"gitHead": "0646bd395a6056657cb0aa93c13699c4a9dbbcdd"
}
@@ -7,7 +7,8 @@ export default {
}
const ipLookupService = req.scope.resolve("ipLookupService")
const regionService = req.scope.resolve("regionService")
const manager = req.scope.resolve("manager")
const countryRepository = req.scope.resolve("countryRepository")
const ip = req.headers["x-forwarded-for"] || req.connection.remoteAddress
@@ -18,15 +19,15 @@ export default {
return
}
// Find region using the country code from ip lookup
const regions = await regionService.list({
countries: data.country_code,
const countryRepo = manager.getCustomRepository(countryRepository)
const country = await countryRepo.findOne({
where: { iso_2: data.country_code.toLowerCase() },
})
// If this region exists, add it to the body of the cart creation request
if (regions[0]) {
req.body.region_id = regions[0]._id.toString()
req.body.country_code = data.country_code
// If country exists, add it to the body of the cart creation request
if (country) {
req.body.region_id = country.region_id
req.body.country_code = country.iso_2
}
next()