From 389af505a5ee4a22eb46bd37bfe31f45b54d8eae Mon Sep 17 00:00:00 2001 From: Labham Jain Date: Sun, 1 Oct 2023 20:33:02 +0530 Subject: [PATCH 1/3] feat: add user deletion route --- .gitignore | 1 + LICENSE | 86 +++++++++-------- data/seed.json | 93 +++++++++++++++---- dump.rdb | Bin 245 -> 80059 bytes medusa-config.js | 2 +- package.json | 6 +- src/api/index.ts | 25 ++++- src/api/routes/admin/restrict-user.ts | 18 ++++ src/api/routes/store/custom-route-handler.ts | 5 - src/api/routes/store/index.ts | 17 ---- src/loaders/README.md | 2 +- src/migrations/README.md | 2 +- tsconfig.json | 2 +- 13 files changed, 174 insertions(+), 85 deletions(-) create mode 100644 src/api/routes/admin/restrict-user.ts delete mode 100644 src/api/routes/store/custom-route-handler.ts delete mode 100644 src/api/routes/store/index.ts diff --git a/.gitignore b/.gitignore index f171bce..7e70a93 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ package-lock.json yarn.lock medusa-db.sql build +.cache \ No newline at end of file diff --git a/LICENSE b/LICENSE index a612ad9..9c3289a 100644 --- a/LICENSE +++ b/LICENSE @@ -2,6 +2,7 @@ Mozilla Public License Version 2.0 ================================== 1. Definitions + -------------- 1.1. "Contributor" @@ -84,6 +85,7 @@ Mozilla Public License Version 2.0 ownership of such entity. 2. License Grants and Conditions + -------------------------------- 2.1. Grants @@ -155,6 +157,7 @@ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities + ------------------- 3.1. Distribution of Source Form @@ -217,6 +220,7 @@ disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation + --------------------------------------------------- If it is impossible for You to comply with any of the terms of this @@ -230,6 +234,7 @@ or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination + -------------- 5.1. The rights granted under this License will terminate automatically @@ -259,48 +264,53 @@ have been validly granted by You or Your distributors under this License prior to termination shall survive termination. ************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * + +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * + ************************************************************************ ************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * + +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * + ************************************************************************ 8. Litigation + ------------- Any litigation relating to this License may be brought only in the @@ -311,6 +321,7 @@ Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. 9. Miscellaneous + ---------------- This License represents the complete agreement concerning the subject @@ -321,6 +332,7 @@ that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License + --------------------------- 10.1. New Versions @@ -357,7 +369,7 @@ Exhibit A - Source Code Form License Notice This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. + file, You can obtain one at . If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE diff --git a/data/seed.json b/data/seed.json index c84682e..020a87d 100644 --- a/data/seed.json +++ b/data/seed.json @@ -1,11 +1,18 @@ { "store": { - "currencies": ["inr", "usd"] + "currencies": [ + "inr", + "usd" + ] }, "users": [ { "email": "admin@medusa-test.com", "password": "supersecret" + }, + { + "email": "labham@curiosta.com", + "password": "labham1234" } ], "regions": [ @@ -14,18 +21,37 @@ "name": "EU", "currency_code": "eur", "tax_rate": 0, - "payment_providers": ["manual"], - "fulfillment_providers": ["manual"], - "countries": ["gb", "de", "dk", "se", "fr", "es", "it"] + "payment_providers": [ + "manual" + ], + "fulfillment_providers": [ + "manual" + ], + "countries": [ + "gb", + "de", + "dk", + "se", + "fr", + "es", + "it" + ] }, { "id": "test-region-na", "name": "NA", "currency_code": "usd", "tax_rate": 0, - "payment_providers": ["manual"], - "fulfillment_providers": ["manual"], - "countries": ["us", "ca"] + "payment_providers": [ + "manual" + ], + "fulfillment_providers": [ + "manual" + ], + "countries": [ + "us", + "ca" + ] } ], "shipping_options": [ @@ -131,11 +157,19 @@ "options": [ { "title": "Size", - "values": ["S", "M", "L", "XL"] + "values": [ + "S", + "M", + "L", + "XL" + ] }, { "title": "Color", - "values": ["Black", "White"] + "values": [ + "Black", + "White" + ] } ], "variants": [ @@ -339,7 +373,12 @@ "options": [ { "title": "Size", - "values": ["S", "M", "L", "XL"] + "values": [ + "S", + "M", + "L", + "XL" + ] } ], "variants": [ @@ -439,7 +478,12 @@ "options": [ { "title": "Size", - "values": ["S", "M", "L", "XL"] + "values": [ + "S", + "M", + "L", + "XL" + ] } ], "variants": [ @@ -539,7 +583,12 @@ "options": [ { "title": "Size", - "values": ["S", "M", "L", "XL"] + "values": [ + "S", + "M", + "L", + "XL" + ] } ], "variants": [ @@ -639,7 +688,12 @@ "options": [ { "title": "Size", - "values": ["S", "M", "L", "XL"] + "values": [ + "S", + "M", + "L", + "XL" + ] } ], "variants": [ @@ -739,7 +793,12 @@ "options": [ { "title": "Size", - "values": ["S", "M", "L", "XL"] + "values": [ + "S", + "M", + "L", + "XL" + ] } ], "variants": [ @@ -838,7 +897,9 @@ "options": [ { "title": "Size", - "values": ["One Size"] + "values": [ + "One Size" + ] } ], "variants": [ @@ -1188,4 +1249,4 @@ "handle": "women" } ] -} +} \ No newline at end of file diff --git a/dump.rdb b/dump.rdb index fb0909131c0c0ed0482a71a754e64e812a62930f..56e54e837cb22c0d9c1e98fa766c3616c9c5131d 100644 GIT binary patch literal 80059 zcmeI533MFydDv$U>@Gl%1Y}FrVTp_7eE^*MfJ6~<4`wifxj2`k01NDbSlrkH1nAP1 zWlQv#HdoW8u|nC76UAwhHa=oI2W`f=)VvorZJaobHQ*u1QRFj?Yg@MZUr+~G$reM< zdF{*ay>H)OIGFwZ*Y|z@Z+`g37KLF4hGFKro%L#^*63fU)^p?lJb;kj?YewsqSkDj z9r|v^WV1G3{oH>zeOvXrg;t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U?;?dS=EUUij#HQz5(4#4I&`>OJJK=Rv)>#n;Xj~PpbF|JYkOd zY(;3)nPc7dzx5A+(Mo=4>or~si-aqbZ z=Z3y86mROm2LTVFAYF~%*SUY(3LbpC^q{u=@MC9j>+P4HeSn9%3@h4P4u@Wmk1#et;OnS h16x@QrmfA-Ui9*#BytlG$P2%=_M6xAn1VgRltf-V<9HqsnDZ06-xrZuN@i6@2Nz6~vEhtJ&%uUKkJ;3mf;WrZ_ zuiE6l97@wA%osJe0#55Qb}%w9FzAEDc*Gb5L@bQWOw0{TEln)U|DSFz{hpU`U@8Dq C2P19( diff --git a/medusa-config.js b/medusa-config.js index 1413e19..e24c1bf 100644 --- a/medusa-config.js +++ b/medusa-config.js @@ -130,7 +130,7 @@ const plugins = [ /** @type {import('@medusajs/admin').PluginOptions} */ options: { autoRebuild: true, - path: "app", + path: "/app", }, }, ]; diff --git a/package.json b/package.json index 5537c65..d689ad1 100644 --- a/package.json +++ b/package.json @@ -24,12 +24,12 @@ }, "dependencies": { "@babel/preset-typescript": "^7.21.5", - "@medusajs/admin": "^6.0.0", + "@medusajs/admin": "^7.1.3", "@medusajs/cache-inmemory": "^1.8.7", "@medusajs/cache-redis": "^1.8.7", "@medusajs/event-bus-local": "^1.9.4", "@medusajs/event-bus-redis": "^1.8.7", - "@medusajs/medusa": "^1.12.0", + "@medusajs/medusa": "^1.17.0", "@medusajs/medusa-cli": "^1.3.15", "babel-preset-medusa-package": "^1.1.19", "body-parser": "^1.20.2", @@ -92,4 +92,4 @@ "engines": { "node": ">=18.0.0" } -} \ No newline at end of file +} diff --git a/src/api/index.ts b/src/api/index.ts index 2596c70..754711a 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,6 +1,25 @@ import { Router } from "express" +import { + getConfigFile, +} from "medusa-core-utils"; +import { ConfigModule } from "@medusajs/medusa"; +import cors from 'cors' +import { restrictUser } from "./routes/admin/restrict-user"; export default (rootDirectory: string): Router | Router[] => { - // add your custom routes here - return [] -} + const { configModule: { projectConfig } } = getConfigFile(rootDirectory, "medusa-config") + const storefrontCorsConfig = { + origin: [...(projectConfig.admin_cors || "")?.split(','), ...(projectConfig.store_cors || "").split(',')], + credentials: true, + } + + const router = Router(); + router.use(cors(storefrontCorsConfig)) + + const endpointHandlers = [restrictUser] + + + endpointHandlers.forEach(endpointHandle => endpointHandle(router)) + + return router +} \ No newline at end of file diff --git a/src/api/routes/admin/restrict-user.ts b/src/api/routes/admin/restrict-user.ts new file mode 100644 index 0000000..ee38136 --- /dev/null +++ b/src/api/routes/admin/restrict-user.ts @@ -0,0 +1,18 @@ +import { CustomerService, authenticate } from "@medusajs/medusa" +import express, { Router } from "express"; + +export const restrictUser = (router: Router) => { + router.use('/admin/restrict-user', express.json()); + + router.post('/admin/restrict-user', authenticate(), async (req, res) => { + const customerService = req.scope.resolve('customerService') as CustomerService; + try { + const result = await customerService.retrieveRegisteredByEmail(req.body.email) + await customerService.delete(result.id); + return res.json({ status: 200, message: 'User has been deleted!' }) + } catch (error) { + return res.status(500).json({ status: 500, message: 'An error occurred!' }) + } + + }) +} \ No newline at end of file diff --git a/src/api/routes/store/custom-route-handler.ts b/src/api/routes/store/custom-route-handler.ts deleted file mode 100644 index de9530d..0000000 --- a/src/api/routes/store/custom-route-handler.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Request, Response } from 'express' - -export default async (req: Request, res: Response): Promise => { - res.sendStatus(200) -} diff --git a/src/api/routes/store/index.ts b/src/api/routes/store/index.ts deleted file mode 100644 index 0631cda..0000000 --- a/src/api/routes/store/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as cors from "cors" -import { Router } from "express" -import * as bodyParser from "body-parser" -import customRouteHandler from "./custom-route-handler" -import { wrapHandler } from "@medusajs/medusa"; - -const storeRouter = Router() -export function getStoreRouter(storeCorsOptions): Router { - storeRouter.use(cors(storeCorsOptions), bodyParser.json()) - - storeRouter.post( - "/store/my-custom-path", - wrapHandler(customRouteHandler) - ) - - return storeRouter -} diff --git a/src/loaders/README.md b/src/loaders/README.md index a5dcfd2..5845453 100644 --- a/src/loaders/README.md +++ b/src/loaders/README.md @@ -16,4 +16,4 @@ import { AwilixContainer } from 'awilix' export default (container: AwilixContainer, config: Record): void | Promise => { /* Implement your own loader. */ } -``` \ No newline at end of file +``` diff --git a/src/migrations/README.md b/src/migrations/README.md index 6964714..bf42227 100644 --- a/src/migrations/README.md +++ b/src/migrations/README.md @@ -26,4 +26,4 @@ export class MyMigration1617703530229 implements MigrationInterface { } } -``` \ No newline at end of file +``` diff --git a/tsconfig.json b/tsconfig.json index 080cb6d..5341b84 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "lib": ["es5", "es6"], "target": "esnext", "allowJs": true, - "esModuleInterop": false, + "esModuleInterop": true, "module": "commonjs", "moduleResolution": "node", "emitDecoratorMetadata": true, From 4c7b7096227f81bec1055d40fa507191a2cd32f3 Mon Sep 17 00:00:00 2001 From: Labham Jain Date: Sun, 1 Oct 2023 20:34:55 +0530 Subject: [PATCH 2/3] fix:remove email from seed --- data/seed.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/data/seed.json b/data/seed.json index 020a87d..496c6e8 100644 --- a/data/seed.json +++ b/data/seed.json @@ -9,10 +9,6 @@ { "email": "admin@medusa-test.com", "password": "supersecret" - }, - { - "email": "labham@curiosta.com", - "password": "labham1234" } ], "regions": [ From 786c8cf5b9a951385def7346232815494c8a4262 Mon Sep 17 00:00:00 2001 From: Labham Jain Date: Mon, 2 Oct 2023 14:38:12 +0530 Subject: [PATCH 3/3] fix: add error message on 500 --- src/api/routes/admin/restrict-user.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/routes/admin/restrict-user.ts b/src/api/routes/admin/restrict-user.ts index ee38136..5c76636 100644 --- a/src/api/routes/admin/restrict-user.ts +++ b/src/api/routes/admin/restrict-user.ts @@ -11,7 +11,7 @@ export const restrictUser = (router: Router) => { await customerService.delete(result.id); return res.json({ status: 200, message: 'User has been deleted!' }) } catch (error) { - return res.status(500).json({ status: 500, message: 'An error occurred!' }) + return res.status(500).json({ status: 500, message: 'An error occurred!', error: error instanceof Error ? error.message : error }) } })