Skip to content

Commit

Permalink
feat(adding medusajs api in apps dir) (mercurjs#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
vholik authored Apr 26, 2024
1 parent a85e10f commit 693a767
Show file tree
Hide file tree
Showing 66 changed files with 3,219 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
apps/
README.md
Binary file added apps/.DS_Store
Binary file not shown.
12 changes: 12 additions & 0 deletions apps/api/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let ignore = [`**/dist`]

// Jest needs to compile this code, but generally we don't want this copied
// to output folders
if (process.env.NODE_ENV !== `test`) {
ignore.push(`**/__tests__`)
}

module.exports = {
presets: [["babel-preset-medusa-package"], ["@babel/preset-typescript"]],
ignore,
}
5 changes: 5 additions & 0 deletions apps/api/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
JWT_SECRET=something
COOKIE_SECRET=something

DATABASE_TYPE="postgres"
REDIS_URL=redis://localhost:6379
48 changes: 48 additions & 0 deletions apps/api/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin', 'prettier'],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: [
'.eslintrc.js',
'**/.prettier*',
'**/.version*',
'**/*.md',
'**/*.json',
'**/*.js',
'**/*.js.map',
'**/*.d.ts',
'**/*.d.ts.map',
],
overrides: [
{
files: ['*'],
rules: {
'prefer-rest-params': 'off',
},
},
],
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/ban-types': [
'error',
{
types: {
Function: false,
},
extendDefaults: true,
},
],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
21 changes: 21 additions & 0 deletions apps/api/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
allow:
- dependency-type: production
groups:
medusa:
patterns:
- "@medusajs*"
- "medusa*"
update-types:
- "minor"
- "patch"
ignore:
- dependency-name: "@medusajs*"
update-types: ["version-update:semver-major"]
- dependency-name: "medusa*"
update-types: ["version-update:semver-major"]
29 changes: 29 additions & 0 deletions apps/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/dist
.env
.DS_Store
/uploads
/node_modules
yarn-error.log

.idea

coverage

!src/**

./tsconfig.tsbuildinfo
package-lock.json
yarn.lock
medusa-db.sql
build
.cache

.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.vscode/

10 changes: 10 additions & 0 deletions apps/api/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"singleQuote": true,
"trailingComma": "es5",
"useTabs": true,
"printWidth": 120,
"endOfLine": "auto",
"arrowParens": "always",
"bracketSpacing": true,
"tabWidth": 4
}
25 changes: 25 additions & 0 deletions apps/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Introduction

This marketplace starter provides a foundational example to help you build and customize your own marketplace using Medusa.js. Begin your project with this starter template and tailor it to meet your specific needs.

# User Management

The user management is facilitated by two additional columns in the user table: `is_admin` and `store_id`. A marketplace admin is identified by the `is_admin` column set to TRUE, and `store_id` set to NULL, indicating an administrative role. Additionally, the `role` column in the user table can be utilized to implement Role-Based Access Control (RBAC) for marketplace and store users.

# Store Setup

Upon registering, a user's account is linked to a new Store entity. The store owner can then invite additional users to their store using Medusa's invite system, enabling team collaboration.

# Shipping Options

Stores have the ability to create and manage their own shipping options, which are then associated with their products. These shipping options are visible in the product responses to ensure clear communication of shipping terms.

# Product Management

When a product is created, the `store_id` of the currently logged-in user's store is associated with the product. This ensures that all products are correctly linked to their respective stores.

# Order Processing

Upon placing an order, the system automatically generates child orders for each vendor involved. This is achieved by iterating through each line item, checking the `store_id`, and grouping items from the same store into a single order. These child orders are then visible in the respective vendor's dashboard for processing.

Feel free to extend and modify this starter as needed to suit your marketplace requirements.
141 changes: 141 additions & 0 deletions apps/api/data/seed-onboarding.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"store": {
"currencies": [
"eur",
"usd"
]
},
"users": [],
"regions": [
{
"id": "test-region-eu",
"name": "EU",
"currency_code": "eur",
"tax_rate": 0,
"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"
]
}
],
"shipping_options": [
{
"name": "PostFake Standard",
"region_id": "test-region-eu",
"provider_id": "manual",
"data": {
"id": "manual-fulfillment"
},
"price_type": "flat_rate",
"amount": 1000
},
{
"name": "PostFake Express",
"region_id": "test-region-eu",
"provider_id": "manual",
"data": {
"id": "manual-fulfillment"
},
"price_type": "flat_rate",
"amount": 1500
},
{
"name": "PostFake Return",
"region_id": "test-region-eu",
"provider_id": "manual",
"data": {
"id": "manual-fulfillment"
},
"price_type": "flat_rate",
"is_return": true,
"amount": 1000
},
{
"name": "I want to return it myself",
"region_id": "test-region-eu",
"provider_id": "manual",
"data": {
"id": "manual-fulfillment"
},
"price_type": "flat_rate",
"is_return": true,
"amount": 0
},
{
"name": "FakeEx Standard",
"region_id": "test-region-na",
"provider_id": "manual",
"data": {
"id": "manual-fulfillment"
},
"price_type": "flat_rate",
"amount": 800
},
{
"name": "FakeEx Express",
"region_id": "test-region-na",
"provider_id": "manual",
"data": {
"id": "manual-fulfillment"
},
"price_type": "flat_rate",
"amount": 1200
},
{
"name": "FakeEx Return",
"region_id": "test-region-na",
"provider_id": "manual",
"data": {
"id": "manual-fulfillment"
},
"price_type": "flat_rate",
"is_return": true,
"amount": 800
},
{
"name": "I want to return it myself",
"region_id": "test-region-na",
"provider_id": "manual",
"data": {
"id": "manual-fulfillment"
},
"price_type": "flat_rate",
"is_return": true,
"amount": 0
}
],
"products": [],
"categories": [],
"publishable_api_keys": [
{
"title": "Development"
}
]
}
Loading

0 comments on commit 693a767

Please sign in to comment.