medusa
medusa copied to clipboard
feat(modules-sdk): External Modules
What:
- Enable External Modules config
- Serve MedusaApp as http or grpc servers (Experimental Only. No TLS)
- http and gRPC clients to communicate with MedusaApp server
// Server
import { MedusaApp, Modules } from "@medusajs/modules-sdk";
async function main() {
const app = await MedusaApp({
sharedResourcesConfig: {
database: {
clientUrl: "postgres://postgres:postgres@localhost:5432/medusa",
},
},
modulesConfig: {
[Modules.PRODUCT]: true,
},
});
app.listen("http", 8000).then(() => {
console.log("MedusaApp Server is running on port 8000");
});
app.listen("grpc", 8001).then(() => {
console.log("Medusa gRPC Server is running on port 8001");
});
}
main();
// Client
import { MODULE_SCOPE, MedusaApp, Modules } from "@medusajs/modules-sdk";
import { IProductModuleService } from "@medusajs/types";
async function main() {
const { modules, query } = await MedusaApp({
sharedResourcesConfig: {
database: {
clientUrl: "postgres://postgres:postgres@localhost:5432/medusa",
},
},
modulesConfig: {
[Modules.PRODUCT]: {
scope: MODULE_SCOPE.EXTERNAL,
server: {
type: "grpc",
url: "localhost:8001",
},
},
},
});
const productService =
modules.productService as unknown as IProductModuleService;
await productService.create(
[
{
title: "Product " + Math.random(),
description: "Product 1",
},
]
);
const products = await query({
product: {
fields: ["id", "title", "description"],
},
});
console.log(products);
}
main();
🦋 Changeset detected
Latest commit: 1bb223348039e50d4676ccf7700b174fbe870a3f
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 3 packages
Name | Type |
---|---|
@medusajs/modules-sdk | Patch |
@medusajs/types | Patch |
integration-tests-http | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
medusa-dashboard | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jun 8, 2024 7:32pm |
3 Ignored Deployments
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
api-reference | ⬜️ Ignored (Inspect) | Jun 8, 2024 7:32pm | ||
docs-ui | ⬜️ Ignored (Inspect) | Visit Preview | Jun 8, 2024 7:32pm | |
medusa-docs | ⬜️ Ignored (Inspect) | Visit Preview | Jun 8, 2024 7:32pm |
/snapshot-this
:rocket: A snapshot release has been made for this PR
Test the snapshots by updating your package.json
with the newly published versions:
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
Latest commit: ca0e0631afb0dd261d372358f6ffe67f92cf7eed
/snapshot-this
:rocket: A snapshot release has been made for this PR
Test the snapshots by updating your package.json
with the newly published versions:
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
Latest commit: 5c6ba674fbdc33e4d2bfe2f95452e1df1030da3f
/snapshot-this
:rocket: A snapshot release has been made for this PR
Test the snapshots by updating your package.json
with the newly published versions:
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
Latest commit: 2f7b53488dbf1cf0a1bb8b2115679f61d543a745