Skip to content

Commit

Permalink
Merge pull request #32 from dimitrio-m/fix/follow-nuxt-author-guide
Browse files Browse the repository at this point in the history
Modified the code so it follows the latest official Nuxt's Module Author Guide and bumped the medusa package version
  • Loading branch information
Baroshem authored Oct 25, 2023
2 parents 6ac9f13 + 1fcee89 commit fe8d7c4
Show file tree
Hide file tree
Showing 8 changed files with 3,808 additions and 2,607 deletions.
30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,37 @@
"e-commerce"
],
"scripts": {
"prepack": "nuxt-module-build",
"prepack": "nuxt-module-build build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"docs": "cd docs && yarn dev",
"medusa": "cd medusa && yarn start",
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
"release": "yarn run lint && yarn run test && yarn run prepack && changelogen --release --output=CHANGELOG.md && yarn publish && git push --follow-tags",
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
"release": "yarn run lint && yarn run test && yarn run dev:prepare && yarn run prepack && changelogen --release --output=CHANGELOG.md && yarn publish && git push --follow-tags",
"lint": "eslint .",
"test": "vitest run",
"test:watch": "vitest watch",
"stackblitz": "cd .stackblitz && yarn && yarn dev"
},
"dependencies": {
"@medusajs/medusa-js": "^1.3.10",
"@nuxt/kit": "^3.2.2",
"@medusajs/medusa-js": "^6.1.3",
"@nuxt/kit": "^3.8.0",
"defu": "^6.1.2"
},
"devDependencies": {
"@nuxt/eslint-config": "^0.1.1",
"@nuxt/module-builder": "^0.2.1",
"@nuxt/schema": "^3.2.2",
"@nuxt/test-utils": "^3.2.2",
"changelogen": "^0.4.1",
"eslint": "^8.34.0",
"nuxt": "^3.2.2",
"vitest": "^0.28.5"
"@nuxt/devtools": "latest",
"@nuxt/eslint-config": "^0.2.0",
"@nuxt/module-builder": "^0.5.2",
"@nuxt/schema": "^3.8.0",
"@nuxt/test-utils": "^3.8.0",
"@types/node": "^18.18.6",
"changelogen": "^0.5.5",
"eslint": "^8.52.0",
"nuxt": "^3.8.0",
"vitest": "^0.33.0"
},
"stackblitz": {
"installDependencies": false,
"startCommand": "yarn stackblitz"
}
}
}
72 changes: 44 additions & 28 deletions playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,57 @@ const { data } = await useFetch('/api/products')

<template>
<section>
<h2 class="text-2xl">Products fetched from Client</h2>
<div class="flex">
<div v-for="product in products" class="mx-2">
<div class="relative rounded-lg shadow-lg">
<img
:src="product.thumbnail"
class="shadow-lg rounded-lg opacity-1 hover:opacity-75 transition duration-300 ease-in-out w-full"
/>
<div class="p-6">
<h5 class="font-bold text-lg mb-3">{{ product.title }}</h5>
<pre class="text-gray-500 mb-4">{{
<h2 class="text-2xl">
Products fetched from Client
</h2>
<div class="flex">
<div
v-for="product in products"
:key="product.key"
class="mx-2"
>
<div class="relative rounded-lg shadow-lg">
<img
:src="product.thumbnail"
class="shadow-lg rounded-lg opacity-1 hover:opacity-75 transition duration-300 ease-in-out w-full"
>
<div class="p-6">
<h5 class="font-bold text-lg mb-3">
{{ product.title }}
</h5>
<pre class="text-gray-500 mb-4">{{
product.variants[0].prices[0].amount
}}</pre>
<p>{{ product.description }}</p>
}}</pre>
<p>{{ product.description }}</p>
</div>
</div>
</div>
</div>
</div>
<h2 class="text-2xl">Products fetched from Server</h2>
<div class="flex">
<div v-for="product in data?.products" class="mx-2">
<div class="relative rounded-lg shadow-lg">
<img
:src="product.thumbnail"
class="shadow-lg rounded-lg opacity-1 hover:opacity-75 transition duration-300 ease-in-out w-full"
/>
<div class="p-6">
<h5 class="font-bold text-lg mb-3">{{ product.title }}</h5>
<pre class="text-gray-500 mb-4">{{
<h2 class="text-2xl">
Products fetched from Server
</h2>
<div class="flex">
<div
v-for="product in data?.products"
:key="product.key"
class="mx-2"
>
<div class="relative rounded-lg shadow-lg">
<img
:src="product.thumbnail"
class="shadow-lg rounded-lg opacity-1 hover:opacity-75 transition duration-300 ease-in-out w-full"
>
<div class="p-6">
<h5 class="font-bold text-lg mb-3">
{{ product.title }}
</h5>
<pre class="text-gray-500 mb-4">{{
product.variants[0].prices[0].amount
}}</pre>
<p>{{ product.description }}</p>
}}</pre>
<p>{{ product.description }}</p>
</div>
</div>
</div>
</div>
</div>
</section>
</template>
13 changes: 7 additions & 6 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ export default defineNuxtConfig({
},
modules: ['../src/module'],
medusa: {
// baseUrl: 'http://localhost:9000',
// apiKey: 'test',
// publishableApiKey: 'test',
// maxRetries: 3
// global: false
// baseUrl: 'http://localhost:9000',
// apiKey: 'test',
// publishableApiKey: 'test',
// maxRetries: 3
// global: false
server: true
}
},
devtools: { enabled: true }
})
13 changes: 11 additions & 2 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"private": true,
"name": "my-module-playground"
}
"name": "my-module-playground",
"type": "module",
"scripts": {
"dev": "nuxi dev",
"build": "nuxi build",
"generate": "nuxi generate"
},
"devDependencies": {
"nuxt": "latest"
}
}
3 changes: 3 additions & 0 deletions playground/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}
3 changes: 3 additions & 0 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
4 changes: 2 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineNuxtModule, addPlugin, createResolver, addImportsDir, extendViteConfig, addTemplate } from '@nuxt/kit'
import { fileURLToPath } from 'url'
import { defu } from 'defu'
import { Config } from '@medusajs/medusa-js'
import type { Config } from '@medusajs/medusa-js'

export type ModuleOptions = Config & { global?: boolean, server: boolean }

Expand All @@ -16,7 +16,7 @@ export default defineNuxtModule<ModuleOptions>({
global: true,
server: false,
},
setup (options, nuxt) {
setup(options, nuxt) {
const resolver = createResolver(import.meta.url)

nuxt.options.runtimeConfig.private = defu(nuxt.options.runtimeConfig.private, {
Expand Down
Loading

1 comment on commit fe8d7c4

@vercel
Copy link

@vercel vercel bot commented on fe8d7c4 Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nuxt-medusa – ./

nuxt-medusa-git-main-baroshem.vercel.app
nuxt-medusa-baroshem.vercel.app
nuxt-medusa.vercel.app

Please sign in to comment.