Skip to content

Commit

Permalink
Merge pull request #37 from curiosta/feat/add-user-deletion
Browse files Browse the repository at this point in the history
feat: add user deletion route
  • Loading branch information
ShivamJoker authored Oct 2, 2023
2 parents d61a6bf + 786c8cf commit 9b1a647
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 85 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ package-lock.json
yarn.lock
medusa-db.sql
build
.cache
86 changes: 49 additions & 37 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Mozilla Public License Version 2.0
==================================

1. Definitions

--------------

1.1. "Contributor"
Expand Down Expand Up @@ -84,6 +85,7 @@ Mozilla Public License Version 2.0
ownership of such entity.

2. License Grants and Conditions

--------------------------------

2.1. Grants
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 <http://mozilla.org/MPL/2.0/>.

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
Expand Down
89 changes: 73 additions & 16 deletions data/seed.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"store": {
"currencies": ["inr", "usd"]
"currencies": [
"inr",
"usd"
]
},
"users": [
{
Expand All @@ -14,18 +17,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": [
Expand Down Expand Up @@ -131,11 +153,19 @@
"options": [
{
"title": "Size",
"values": ["S", "M", "L", "XL"]
"values": [
"S",
"M",
"L",
"XL"
]
},
{
"title": "Color",
"values": ["Black", "White"]
"values": [
"Black",
"White"
]
}
],
"variants": [
Expand Down Expand Up @@ -339,7 +369,12 @@
"options": [
{
"title": "Size",
"values": ["S", "M", "L", "XL"]
"values": [
"S",
"M",
"L",
"XL"
]
}
],
"variants": [
Expand Down Expand Up @@ -439,7 +474,12 @@
"options": [
{
"title": "Size",
"values": ["S", "M", "L", "XL"]
"values": [
"S",
"M",
"L",
"XL"
]
}
],
"variants": [
Expand Down Expand Up @@ -539,7 +579,12 @@
"options": [
{
"title": "Size",
"values": ["S", "M", "L", "XL"]
"values": [
"S",
"M",
"L",
"XL"
]
}
],
"variants": [
Expand Down Expand Up @@ -639,7 +684,12 @@
"options": [
{
"title": "Size",
"values": ["S", "M", "L", "XL"]
"values": [
"S",
"M",
"L",
"XL"
]
}
],
"variants": [
Expand Down Expand Up @@ -739,7 +789,12 @@
"options": [
{
"title": "Size",
"values": ["S", "M", "L", "XL"]
"values": [
"S",
"M",
"L",
"XL"
]
}
],
"variants": [
Expand Down Expand Up @@ -838,7 +893,9 @@
"options": [
{
"title": "Size",
"values": ["One Size"]
"values": [
"One Size"
]
}
],
"variants": [
Expand Down Expand Up @@ -1188,4 +1245,4 @@
"handle": "women"
}
]
}
}
Binary file modified dump.rdb
Binary file not shown.
2 changes: 1 addition & 1 deletion medusa-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const plugins = [
/** @type {import('@medusajs/admin').PluginOptions} */
options: {
autoRebuild: true,
path: "app",
path: "/app",
},
},
];
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -92,4 +92,4 @@
"engines": {
"node": ">=18.0.0"
}
}
}
25 changes: 22 additions & 3 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -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<ConfigModule>(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
}
Loading

0 comments on commit 9b1a647

Please sign in to comment.