docs: update imports and package names across docs (#9375)

* docs: update imports and package names across docs
+ reference configs

* generate files

* fix import

* change preview to rc
This commit is contained in:
Shahed Nasser
2024-10-01 11:03:42 +02:00
committed by GitHub
parent c726ed54f5
commit 2e16949979
196 changed files with 1379 additions and 1491 deletions
@@ -16,10 +16,10 @@ Start by creating a new directory for your module. For example, `src/modules/my-
Create the file `src/modules/my-cache/service.ts` that holds the implementation of the cache service.
The Cache Module's main service must implement the `ICacheService` interface imported from `@medusajs/types`:
The Cache Module's main service must implement the `ICacheService` interface imported from `@medusajs/framework/types`:
```ts title="src/modules/my-cache/service.ts"
import { ICacheService } from "@medusajs/types"
import { ICacheService } from "@medusajs/framework/types"
class MyCacheService implements ICacheService {
get<T>(key: string): Promise<T> {
@@ -135,7 +135,7 @@ Create the file `src/modules/my-cache/index.ts` with the following content:
```ts title="src/modules/my-cache/index.ts"
import MyCacheService from "./service"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
export default Module("my-cache", {
service: MyCacheService,
@@ -153,7 +153,7 @@ To use your Cache Module, add it to the `modules` object exported as part of the
For example:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -14,30 +14,18 @@ For production, its recommended to use modules like [Redis Cache Module](../r
---
## Install the In-Memory Cache Module
## Register the In-Memory Cache Module
<Note>
The In-Memory Cache Module is installed by default in your application.
The In-Memory Cache Module is registered by default in your application.
</Note>
To install the In-Memory Cache Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/cache-inmemory@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
Add the module into the `modules` property of the exported object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -45,7 +33,7 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.CACHE]: {
resolve: "@medusajs/cache-inmemory",
resolve: "@medusajs/medusa/cache-inmemory",
options: {
// optional options
},
@@ -10,7 +10,7 @@ The Redis Cache Module uses Redis to cache data in your store. In production, it
---
## Install the Redis Cache Module
## Register the Redis Cache Module
<Prerequisites items={[
{
@@ -19,26 +19,14 @@ The Redis Cache Module uses Redis to cache data in your store. In production, it
}
]} />
To install Redis Cache Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/cache-redis@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
Add the module into the `modules` property of the exported object in `medusa-config.js`:
export const highlights = [
["11", "redisUrl", "The Redis connection URL."]
]
```js title="medusa-config.js" highlights={highlights}
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -46,7 +34,7 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.CACHE]: {
resolve: "@medusajs/cache-redis",
resolve: "@medusajs/medusa/cache-redis",
options: {
redisUrl: process.env.CACHE_REDIS_URL,
},
@@ -166,6 +154,8 @@ CACHE_REDIS_URL=<YOUR_REDIS_URL>
</Table.Body>
</Table>
---
## Test the Module
To test the module, start the Medusa application: