docs: add documentation for v1.8 (#3669)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
description: 'Learn about the different configurations available in a Medusa backend. This includes configurations related to the database, CORS, plugins, redis, and more.'
|
||||
description: 'Learn about the different configurations available in a Medusa backend. This includes configurations related to the database, CORS, plugins, and more.'
|
||||
---
|
||||
|
||||
# Configure Medusa Backend
|
||||
@@ -8,32 +8,18 @@ In this document, you’ll learn what configurations you can add to your Medusa
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This document assumes you already followed along with the [“Set up your development environment” documentation](./prepare-environment.mdx) and have [installed a Medusa backend](./install.mdx#create-a-medusa-backend).
|
||||
This document assumes you already followed along with the [Prepare Environment documentation](./prepare-environment.mdx) and have [installed a Medusa backend](./install.mdx#create-a-medusa-backend).
|
||||
|
||||
---
|
||||
|
||||
## Medusa Configurations File
|
||||
|
||||
The configurations for your Medusa backend are in `medusa-config.js`. This includes database, Redis, and plugin configurations, among other configurations.
|
||||
The configurations for your Medusa backend are in `medusa-config.js`. This includes database, modules, and plugin configurations, among other configurations.
|
||||
|
||||
Some of the configurations mentioned in this document are already defined in `medusa-config.js` with default values. It’s important that you know what these configurations are used for and how to set them.
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
In your configurations, you’ll often use environment variables. For example, when using API keys or setting your database URL.
|
||||
|
||||
By default, Medusa loads environment variables from the system’s environment variables. Any different method you prefer to use or other location you’d prefer to load environment variables from you need to manually implement.
|
||||
|
||||
:::info
|
||||
|
||||
This change in how environment variables are loaded was introduced in version 1.3.0. You can learn more in the [upgrade guide for version 1.3.0](../../upgrade-guides/medusa-core/1-3-0.md).
|
||||
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
## Database Configuration
|
||||
|
||||
Medusa supports two database types: SQLite and PostgreSQL.
|
||||
@@ -131,9 +117,15 @@ module.exports = {
|
||||
|
||||
## Redis
|
||||
|
||||
Medusa uses Redis to handle the event queue, among other usages. You need to set Redis URL in the configurations:
|
||||
:::note
|
||||
|
||||
```jsx
|
||||
As of v1.8 of the Medusa core package, Redis is only used for scheduled jobs. For events handling, it's now moved into a module and can be configured as explained [here](#modules).
|
||||
|
||||
:::
|
||||
|
||||
You must first have Redis installed. You can refer to [Redis's installation guide](https://redis.io/docs/getting-started/installation/). You need to set Redis URL in the configurations:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
projectConfig: {
|
||||
// ...other configurations
|
||||
@@ -144,7 +136,7 @@ module.exports = {
|
||||
|
||||
Where `REDIS_URL` is the URL used to connect to Redis. The format of the connection string is `redis[s]://[[username][:password]@][host][:port][/db-number]`.
|
||||
|
||||
If you omit this configuration, events will not be emitted and subscribers will not work.
|
||||
If you omit this configuration, scheduled jobs will not work.
|
||||
|
||||
:::tip
|
||||
|
||||
@@ -160,12 +152,6 @@ REDIS_URL=<YOUR_REDIS_URL>
|
||||
|
||||
Where `<YOUR_REDIS_URL>` is the URL of your Redis backend.
|
||||
|
||||
:::info
|
||||
|
||||
You can learn more about Subscribers and events in the [Subscriber documentation](../events/create-subscriber.md).
|
||||
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
## JWT Secret
|
||||
@@ -203,7 +189,7 @@ In a development environment, if this option is not set the default secret is
|
||||
|
||||
This configuration is used to sign the session ID cookie. To set the cookie secret:
|
||||
|
||||
```jsx
|
||||
```js
|
||||
module.exports = {
|
||||
projectConfig: {
|
||||
// ...other configurations
|
||||
@@ -273,7 +259,7 @@ The examples above apply to both Admin and Store CORS.
|
||||
|
||||
To make sure your Admin dashboard can access the Medusa backend’s admin endpoints, set this configuration:
|
||||
|
||||
```jsx
|
||||
```js
|
||||
module.exports = {
|
||||
projectConfig: {
|
||||
// ...other configurations
|
||||
@@ -302,7 +288,7 @@ Make sure that the URL is without a backslash at the end. For example, you shoul
|
||||
|
||||
To make sure your Storefront dashboard can access the Medusa backend, set this configuration:
|
||||
|
||||
```jsx
|
||||
```js
|
||||
module.exports = {
|
||||
projectConfig: {
|
||||
// ...other configurations
|
||||
@@ -331,7 +317,7 @@ Make sure that the URL is without a backslash at the end. For example, you shoul
|
||||
|
||||
## Plugins
|
||||
|
||||
On your Medusa backend, you can use Plugins to add custom features or integrate third-party services. For example, installing a plugin to use Stripe as a payment provider.
|
||||
On your Medusa backend, you can use Plugins to add custom features or integrate third-party services. For example, installing a plugin to use Stripe as a payment processor.
|
||||
|
||||
:::info
|
||||
|
||||
@@ -385,7 +371,61 @@ It is recommended to use environment variables to store values of options instea
|
||||
|
||||
---
|
||||
|
||||
## Modules
|
||||
|
||||
In Medusa, commerce and core logic are modularized to allow developers to extend or replace certain modules with custom implementations.
|
||||
|
||||
:::tip
|
||||
|
||||
You can learn more about Modules in the [Modules Overview documentation](../modules/overview.mdx).
|
||||
|
||||
:::
|
||||
|
||||
Aside from installing the module with NPM, you need to add into the exported object in `medusa-config.js`. For example:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
moduleType: {
|
||||
resolve: "<module_name>",
|
||||
options: {
|
||||
// options if necessary
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
`moduleType` and `<module_name>` are just placeholder that should be replaced based on the type of Module you're adding. For example, if you used the default Medusa starter to create your backend, you should have an `eventBus` module installed:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
eventBus: {
|
||||
resolve: "@medusajs/event-bus-local",
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Each module can have its own options. You must refer to the module's documentation to learn about its options.
|
||||
|
||||
### Recommended Event Bus Modules
|
||||
|
||||
In the default Medusa starter, the local event bus module is used. This module is good for testing out Medusa and during development, but it's highly recommended to use the [Redis event module](../events/modules/redis.md) instead for better development experience and during production.
|
||||
|
||||
### Recommended Cache Modules
|
||||
|
||||
In the default Medusa starter, the in-memory cache module is used. This module is good for testing out Medusa and during development, but it's highly recommended to use the [Redis cache module](../cache/modules/redis.md) instead for better development experience and during production.
|
||||
|
||||
---
|
||||
|
||||
## See Also
|
||||
|
||||
- [Medusa architecture overview](../fundamentals/architecture-overview.md)
|
||||
- [Plugins](../plugins/overview.mdx)
|
||||
- [Plugins](../plugins/overview.mdx)
|
||||
- [Modules](../modules/overview.mdx)
|
||||
|
||||
@@ -85,7 +85,7 @@ Medusa backend is made up of different resources that make it a powerful server.
|
||||
|
||||
### Set Up Development Environment
|
||||
|
||||
For an optimal experience developing with Medusa and to make sure you can use its advanced functionalities, you'll need to install more tools such as Redis or PostgreSQL.
|
||||
For an optimal experience developing with Medusa and to make sure you can use its advanced functionalities, you'll need to install more tools such as PostgreSQL.
|
||||
|
||||
Follow [this documentation to learn how to set up your development environment](../../development/backend/prepare-environment.mdx).
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
description: 'Learn how to prepare your development environment while using Medusa. This guide includes how to install Node.js, Git, Medusa CLI tool, PostgreSQL, and Redis.'
|
||||
description: 'Learn how to prepare your development environment while using Medusa. This guide includes how to install Node.js, Git, Medusa CLI tool, and PostgreSQL.'
|
||||
---
|
||||
|
||||
import styles from './development.module.css';
|
||||
@@ -213,73 +213,6 @@ Where:
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Redis
|
||||
|
||||
Medusa uses Redis as the event queue in the backend. If you want to use subscribers to handle events such as when an order is placed and perform actions based on the events, then you need to install and configure Redis.
|
||||
|
||||
If you don’t install and configure Redis with your Medusa backend, then it will work without any events-related features.
|
||||
|
||||
:::tip
|
||||
|
||||
After installing Redis, check out the [Configure your Backend documentation](./configurations.md#redis) to learn how to configure Redis to work with Medusa.
|
||||
|
||||
:::
|
||||
|
||||
<Tabs groupId="operating-systems" wrapperClassName={styles.osTabs}>
|
||||
<TabItem value="windows" label="Windows">
|
||||
|
||||
To use Redis on Windows, you must have [Windows Subsystem for Linux (WSL2) enabled](https://docs.microsoft.com/en-us/windows/wsl/install). This lets you run Linux binaries on Windows.
|
||||
|
||||
After installing and enabling WSL2, if you use an Ubuntu distribution you can run the following commands to install Redis:
|
||||
|
||||
```bash
|
||||
sudo apt-add-repository ppa:redislabs/redis
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade
|
||||
sudo apt-get install redis-server
|
||||
|
||||
## Start Redis server
|
||||
sudo service redis-server start
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="linux" label="Linux">
|
||||
|
||||
If you use Ubuntu you can use the following commands to install Redis:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://packages.redis.io/gpg | \
|
||||
sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
|
||||
|
||||
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" \
|
||||
| sudo tee /etc/apt/sources.list.d/redis.list
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install redis
|
||||
|
||||
## Start Redis server
|
||||
sudo service redis-server start
|
||||
```
|
||||
|
||||
For other distributions, you can check out [Redis’ guide on this](https://redis.io/docs/getting-started/installation/install-redis-on-linux/).
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="macos" label="macOS">
|
||||
|
||||
You can install Redis on macOS using Homebrew with the following command:
|
||||
|
||||
```bash
|
||||
brew install redis
|
||||
|
||||
## Start Redis server
|
||||
brew services start redis
|
||||
```
|
||||
|
||||
To install Redis without Homebrew you can check out [Redis’s guide on installing it from source](https://redis.io/docs/getting-started/installation/install-redis-from-source/).
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
---
|
||||
|
||||
## See Also
|
||||
|
||||
Reference in New Issue
Block a user