Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
@@ -12,7 +12,7 @@ Thank you for considering contributing to Medusa! This document will outline how
|
||||
|
||||
1. Before you start working on a change please make sure that there is an issue for what you will be working on. You can either find and [existing issue](https://github.com/medusajs/medusa/issues) or [open a new issue](https://github.com/medusajs/medusa/issues/new) if none exists. Doing this makes sure that others can contribute with thoughts or suggest alternatives, ultimately making sure that we only add changes that make
|
||||
|
||||
2. When you are ready to start working on a change you should first [fork the Medusa repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) and [branch out]](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-and-deleting-branches-within-your-repository) from the `develop` branch.
|
||||
2. When you are ready to start working on a change you should first [fork the Medusa repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) and [branch out](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-and-deleting-branches-within-your-repository) from the `develop` branch.
|
||||
3. Make your changes.
|
||||
4. [Open a pull request towards the develop branch in the Medusa repo](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork). Within a couple of days a Medusa team member will review, comment and eventually approve your PR.
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<h4 align="center">
|
||||
<a href="https://github.com/medusajs/admin">Medusa Admin</a> |
|
||||
<a href="https://www.medusajs.com">Website</a> |
|
||||
<a href="https://roadmap.medusa-commerce.com">Roadmap</a> |
|
||||
<a href="https://www.medusajs.com/blog">Blog</a> |
|
||||
<a href="https://www.linkedin.com/company/medusa-commerce">LinkedIn</a> |
|
||||
<a href="https://twitter.com/medusajs">Twitter</a> |
|
||||
@@ -69,8 +68,8 @@ Write-ups for all features will be made available in [Github discussions](https:
|
||||
|
||||
### Q1
|
||||
- [x] Admin revamp
|
||||
- [ ] Tax API
|
||||
- [ ] Strategy pattern
|
||||
- [x] Tax API
|
||||
- [x] Strategy pattern
|
||||
- [ ] Promotions API
|
||||
- [ ] Bulk import / export
|
||||
|
||||
|
||||
@@ -63,6 +63,10 @@
|
||||
{
|
||||
"name": "Product Variant",
|
||||
"x-resourceId": "product_variant"
|
||||
},
|
||||
{
|
||||
"name": "OAuth",
|
||||
"x-resourceId": "OAuth"
|
||||
}
|
||||
],
|
||||
"servers": [
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ routes:
|
||||
path: /products/:id
|
||||
route: /products
|
||||
description: >
|
||||
A product represents the object, that are to be sold on the website. A product can have variants, that differ by e.g. size and color.
|
||||
A product represents the object, that is to be sold on the website. A product can have variants, that differ by e.g. size and color.
|
||||
endpoints:
|
||||
- path: /:id
|
||||
method: GET
|
||||
|
||||
@@ -61,7 +61,7 @@ And that's all! You've now enabled Algolia for your Medusa store engine. The plu
|
||||
|
||||
**Usage**
|
||||
|
||||
This article will not go too much into depth about how the search functionality works under the hood when querying the API. We refer to the [previous article on MeiliSearch](https://www.medusa-commerce.com/post/meilisearch-and-medusa) if this is of your interest. In there, you will find a quick showcase using Postman as well as a thorough walkthrough of how you can display the results in your storefront using ReactJS (GatsbyJS).
|
||||
This article will not go too much into depth about how the search functionality works under the hood when querying the API. We refer to the [previous article on MeiliSearch](https://www.medusajs.com/post/meilisearch-and-medusa) if this is of your interest. In there, you will find a quick showcase using Postman as well as a thorough walkthrough of how you can display the results in your storefront using ReactJS (GatsbyJS).
|
||||
|
||||
Instead, to illustrate the power of our Search API and search engine plugins, we'll switch out a MeiliSearch plugin with our new Algolia plugin in a store with existing products. Upon restarting the server with the new configuration, your products will automatically be fed into Algolia and the search functionality in your frontend will remain unchanged.
|
||||
|
||||
|
||||
@@ -27,7 +27,11 @@ If you want to jump straight to the code for this series you can checkout:
|
||||
|
||||
## Prerequisites
|
||||
|
||||
> For a full guide to how to set up your development environment for Medusa please see [the tutorial](https://docs.medusa-commerce.com/tutorials/set-up-your-development-environment)
|
||||
:::note
|
||||
|
||||
For a full guide to how to set up your development environment for Medusa please see [the tutorial](../tutorial/set-up-your-development-environment/)
|
||||
|
||||
:::
|
||||
|
||||
In order to get you started with your Gatsby, Contentful, Medusa store you must complete a couple of installations:
|
||||
|
||||
@@ -136,7 +140,7 @@ module.exports = {
|
||||
|
||||
#### `/src`
|
||||
|
||||
In the `/src` directory there are 4 special subdirectories that are added for you already. These special directories can be used to add custom functionality to your store. Custom functionality can include custom endpoints (configured in `/api`), custom business logic (configured in `/services`), pub/sub-like subscriptions for asyncrhonous integration tasks (configured in `/subscribers`) and finally loader functions to be called when your Medusa server starts up (configured in `/loaders`). If you want to learn more about how to add custom functionality you can checkout [the tutorial](https://docs.medusa-commerce.com/tutorials/adding-custom-functionality).
|
||||
In the `/src` directory there are 4 special subdirectories that are added for you already. These special directories can be used to add custom functionality to your store. Custom functionality can include custom endpoints (configured in `/api`), custom business logic (configured in `/services`), pub/sub-like subscriptions for asyncrhonous integration tasks (configured in `/subscribers`) and finally loader functions to be called when your Medusa server starts up (configured in `/loaders`). If you want to learn more about how to add custom functionality you can checkout [the tutorial](https://docs.medusajs.com/tutorials/adding-custom-functionality).
|
||||
|
||||
#### `/data`
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ In order to work with images in Medusa, you need a file service plugin responsib
|
||||
|
||||
### Before you start
|
||||
|
||||
At this point, you should have an instance of our store engine running. If not, we have a [full guide](https://docs.medusa-commerce.com/tutorial/set-up-your-development-environment) for setting up your local environment.
|
||||
At this point, you should have an instance of our store engine running. If not, we have a [full guide](https://docs.medusajs.com/tutorial/set-up-your-development-environment) for setting up your local environment.
|
||||
|
||||
### Set up MinIO
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ In order to work with images in Medusa, you need a file service plugin responsib
|
||||
|
||||
### Before you start
|
||||
|
||||
At this point, you should have an instance of our store engine running. If not, we have a [full guide](https://docs.medusa-commerce.com/tutorial/set-up-your-development-environment) for setting up your local environment.
|
||||
At this point, you should have an instance of our store engine running. If not, we have a [full guide](https://docs.medusajs.com/tutorial/set-up-your-development-environment) for setting up your local environment.
|
||||
|
||||
### Set up AWS
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ In many cases you will want to track other events that are specific to your stor
|
||||
|
||||
## Tracking custom events
|
||||
|
||||
Building from the custom functionality that can be guided by [the tutorial](https://docs.medusa-commerce.com/tutorial/adding-custom-functionality) in Medusa docs, imagine that you want to track all welcome opt-ins.
|
||||
Building from the custom functionality that can be guided by [the tutorial](https://docs.medusajs.com/tutorial/adding-custom-functionality) in Medusa docs, imagine that you want to track all welcome opt-ins.
|
||||
|
||||
The `segmentService` exposes a `track` method that wraps [Segment's Track Spec](https://segment.com/docs/connections/spec/track/), allowing you to send events to the Segment from anywhere in your Medusa project.
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
[View plugin here](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-sendgrid)
|
||||
|
||||
|
||||
https://user-images.githubusercontent.com/59018053/154807282-1e72671f-1936-411d-b914-e05c6597693a.mp4
|
||||
|
||||
<div>
|
||||
<video width="100%" height="100%" playsinline autoplay muted controls>
|
||||
<source src="https://user-images.githubusercontent.com/59018053/154807282-1e72671f-1936-411d-b914-e05c6597693a.mp4" type="video/mp4" />
|
||||
</video>
|
||||
</div>
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
In order to work with images in Medusa, you need a file service plugin responsible for hosting. Following this guide will allow you to upload images to DigitalOcean Spaces.
|
||||
|
||||
|
||||
https://user-images.githubusercontent.com/59018053/154808767-7c030254-1879-41fd-a71c-b31c5508d8a4.mp4
|
||||
|
||||
<div>
|
||||
<video width="100%" height="100%" playsinline autoplay muted controls>
|
||||
<source src="https://user-images.githubusercontent.com/59018053/154808767-7c030254-1879-41fd-a71c-b31c5508d8a4.mp4" type="video/mp4" />
|
||||
</video>
|
||||
</div>
|
||||
|
||||
### Before you start
|
||||
|
||||
At this point, you should have an instance of our store engine running. If not, we have a [full guide](https://docs.medusa-commerce.com/tutorial/set-up-your-development-environment) for setting up your local environment.
|
||||
At this point, you should have an instance of our store engine running. If not, we have a [full guide](https://docs.medusajs.com/tutorial/set-up-your-development-environment) for setting up your local environment.
|
||||
|
||||
### Set up DigitalOcean
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ Both projects are open-source, headless, and built with Node.js. They use a very
|
||||
|
||||
## Installation
|
||||
|
||||
The following guide for setting up the plugin assumes, that you are familiar with both Strapi and Medusa. If this is not the case, visit the official [Medusa](https://docs.medusa-commerce.com/tutorial/set-up-your-development-environment) and [Strapi](https://strapi.io/documentation/developer-docs/latest/getting-started/introduction.html) documentation.
|
||||
The following guide for setting up the plugin assumes, that you are familiar with both Strapi and Medusa. If this is not the case, visit the official [Medusa](https://docs.medusajs.com/tutorial/set-up-your-development-environment) and [Strapi](https://strapi.io/documentation/developer-docs/latest/getting-started/introduction.html) documentation.
|
||||
|
||||
### Setting up Medusa
|
||||
|
||||
|
||||
@@ -2,15 +2,18 @@
|
||||
|
||||
[View plugin here](https://github.com/medusajs/medusa/tree/master/packages/medusa-payment-stripe)
|
||||
|
||||
|
||||
https://user-images.githubusercontent.com/59018053/154807206-6fbda0a6-bf3e-4e39-9fc2-f11710afe0b9.mp4
|
||||
<div>
|
||||
<video width="100%" height="100%" playsinline autoplay muted controls>
|
||||
<source src="https://user-images.githubusercontent.com/59018053/154807206-6fbda0a6-bf3e-4e39-9fc2-f11710afe0b9.mp4" type="video/mp4" />
|
||||
</video>
|
||||
</div>
|
||||
|
||||
|
||||
### Introduction
|
||||
|
||||
Handling payments is at the core of every commerce system; it allows us to run our businesses. Consequently, a vast landscape of payment providers has developed, each with varying cost models, implementational specifications, and analytical capabilities.
|
||||
|
||||
As a consequence, one might ask, which one(s) should I choose? Medusa makes exchanging enabled payment providers easy through its unified payment API. Here, one may select payment provider plugins already existing ([PayPal](https://docs.medusa-commerce.com/add-plugins/paypal), [Klarna](https://docs.medusa-commerce.com/add-plugins/klarna), and Stripe), or develop new ones.
|
||||
As a consequence, one might ask, which one(s) should I choose? Medusa makes exchanging enabled payment providers easy through its unified payment API. Here, one may select payment provider plugins already existing ([PayPal](https://docs.medusajs.com/add-plugins/paypal), [Klarna](https://docs.medusajs.com/add-plugins/klarna), and Stripe), or develop new ones.
|
||||
|
||||
Using the `medusa-payment-stripe` plugin, this guide will show you how to set up your Medusa project with Stripe as a payment provider.
|
||||
|
||||
@@ -18,7 +21,7 @@ Using the `medusa-payment-stripe` plugin, this guide will show you how to set up
|
||||
|
||||
### Prerequisites
|
||||
|
||||
This guide assumes that you have set up a medusa project (See [this guide](https://docs.medusa-commerce.com/tutorial/creating-your-medusa-server)). Furthermore, this guide will be using the Gatsby starter as our storefront (See [this guide](https://docs.medusa-commerce.com/starters/gatsby-medusa-starter)) and the Admin panel to manage our store (See the github installation guide [here](https://github.com/medusajs/admin)).
|
||||
This guide assumes that you have set up a medusa project (See [this guide](https://docs.medusajs.com/tutorial/creating-your-medusa-server)). Furthermore, this guide will be using the Gatsby starter as our storefront (See [this guide](https://docs.medusajs.com/starters/gatsby-medusa-starter)) and the Admin panel to manage our store (See the github installation guide [here](https://github.com/medusajs/admin)).
|
||||
|
||||
### Installation
|
||||
|
||||
|
||||
206
docs/content/advanced/backend/endpoints/add-admin.md
Normal file
206
docs/content/advanced/backend/endpoints/add-admin.md
Normal file
@@ -0,0 +1,206 @@
|
||||
---
|
||||
title: Add Endpoint for Admin
|
||||
---
|
||||
|
||||
# Add Endpoint for Admin
|
||||
|
||||
In this document, you’ll learn how to add a custom endpoint in the Backend that you can use from the Admin.
|
||||
|
||||
## Overview
|
||||
|
||||
Custom endpoints reside under the `src/api` directory in your Medusa Backend. To define a new endpoint, you can add the file `index.js` under the `src/api` directory. This file should export a function that returns an Express router.
|
||||
|
||||
Your endpoint can be under any path you wish. By Medusa’s conventions, all Admin REST APIs are prefixed by `/admin`. For example, the `/admin/products` lets you retrieve the products to display them on your Admin.
|
||||
|
||||
## Implementation
|
||||
|
||||
To create a new endpoint, start by creating a new file in `src/api` called `index.js`. At its basic format, `index.js` should look something like this:
|
||||
|
||||
```js
|
||||
import { Router } from "express"
|
||||
|
||||
export default () => {
|
||||
const router = Router()
|
||||
|
||||
router.get("/admin/hello", (req, res) => {
|
||||
res.json({
|
||||
message: "Welcome to Your Store!"
|
||||
})
|
||||
})
|
||||
|
||||
return router
|
||||
}
|
||||
```
|
||||
|
||||
This exports a function that returns an Express router. In that function, you can create one or more endpoints. In the example above, you create the endpoint `/admin/hello`.
|
||||
|
||||
Now, if you run your server and send a request to `/admin/hello`, you will receive a JSON response message.
|
||||
|
||||
> Custom endpoints are compiled into the `dist` directory of your Backend when you run your server using `medusa develop`, while it’s running, and when you run `npm run build`.
|
||||
|
||||
## Accessing Endpoints from Admin
|
||||
|
||||
If you’re customizing the admin dashboard or creating your own, you need to use the `cors` library. A `OPTIONS` request should be added for each route and handle the requests with the `cors` library.
|
||||
|
||||
First, you need to import your Medusa’s configurations along with the `cors` library:
|
||||
|
||||
```js
|
||||
import cors from "cors"
|
||||
import { projectConfig } from "../../medusa-config"
|
||||
```
|
||||
|
||||
Then, create an object that will hold the CORS configurations:
|
||||
|
||||
```js
|
||||
const corsOptions = {
|
||||
origin: projectConfig.admin_cors.split(","),
|
||||
credentials: true,
|
||||
}
|
||||
```
|
||||
|
||||
Finally, for each route you add, create an `OPTIONS` request:
|
||||
|
||||
```js
|
||||
router.options("/admin/hello", cors(corsOptions))
|
||||
router.get("/admin/hello", (req, res) => {
|
||||
//...
|
||||
});
|
||||
```
|
||||
|
||||
## Multiple Endpoints
|
||||
|
||||
### Same File
|
||||
|
||||
You can add more than one endpoints in `src/api/index.js`:
|
||||
|
||||
```js
|
||||
router.get("/admin/hello", (req, res) => {
|
||||
res.json({
|
||||
message: "Welcome to Your Store!"
|
||||
})
|
||||
})
|
||||
|
||||
router.get("/admin/bye", (req, res) => {
|
||||
res.json({
|
||||
message: "Come back again!"
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
### Multiple Files
|
||||
|
||||
Alternatively, you can add multiple files for each endpoint or set of endpoints for readability and easy maintenance.
|
||||
|
||||
To do that with the previous example, first, create the file `src/api/hello.js` with the following content:
|
||||
|
||||
```js
|
||||
export default (router) => {
|
||||
router.get("/admin/hello", (req, res) => {
|
||||
res.json({
|
||||
message: "Welcome to Your Store!"
|
||||
})
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
You export a function that receives an Express router as a parameter and adds the endpoint `admin/hello` to it.
|
||||
|
||||
Next, create the file `src/api/bye.js` with the following content:
|
||||
|
||||
```js
|
||||
export default (router) => {
|
||||
router.get("/admin/bye", (req, res) => {
|
||||
res.json({
|
||||
message: "Come back again!"
|
||||
})
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
Again, you export a function that receives an Express router as a parameter and adds the endpoint `admin/bye` to it.
|
||||
|
||||
Finally, in `src/api/index.js` import the two functions at the beginning of the file:
|
||||
|
||||
```js
|
||||
import helloRoute from "./hello"
|
||||
import byeRoute from "./bye"
|
||||
```
|
||||
|
||||
and in the exported function, call each of the functions passing them the Express router:
|
||||
|
||||
```js
|
||||
export default () => {
|
||||
const router = Router()
|
||||
|
||||
helloRoute(router)
|
||||
byeRoute(router)
|
||||
|
||||
return router
|
||||
}
|
||||
```
|
||||
|
||||
## Use Services
|
||||
|
||||
Services in Medusa bundle a set of functionalities into one class. Then, you can use that class anywhere in your Backend. For example, you can use the `ProductService` to retrieve products or perform operations like creating or updating a product.
|
||||
|
||||
You can retrieve any registered service in your endpoint using `req.scope.resolve` passing it the service’s registration name.
|
||||
|
||||
Here’s an example of an endpoint that retrieves the count of products in your store:
|
||||
|
||||
```js
|
||||
router.get('/admin/products/count', (req, res) => {
|
||||
const productService = req.scope.resolve('productService')
|
||||
|
||||
productService
|
||||
.count()
|
||||
.then((count) => {
|
||||
res.json({
|
||||
count
|
||||
})
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
The `productService` has a `count` method that returns a Promise. This Promise resolves to the count of the products. You return a JSON of the product count.
|
||||
|
||||
## Protected Routes
|
||||
|
||||
Protected routes are routes that should be accessible by logged-in users only.
|
||||
|
||||
To make a route protected, first, import the `authenticate` middleware:
|
||||
|
||||
```js
|
||||
import authenticate from '@medusajs/medusa/dist/api/middlewares/authenticate'
|
||||
```
|
||||
|
||||
Then, add the middleware to your route:
|
||||
|
||||
```js
|
||||
router.get('/store/products/count', authenticate(), (req, res) => {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
Now, only authenticated users can access this endpoint.
|
||||
|
||||
### Accessing Current User
|
||||
|
||||
You can get the logged-in user ID using `req.user`:
|
||||
|
||||
```js
|
||||
const id = req.user.userId
|
||||
```
|
||||
|
||||
To get the user’s details, you can use the `userService`:
|
||||
|
||||
```js
|
||||
const id = req.user.userId
|
||||
const userService = req.scope.resolve("userService")
|
||||
|
||||
const user = await userService.retrieve(id)
|
||||
```
|
||||
|
||||
## What’s Next 🚀
|
||||
|
||||
- [Learn how to add an endpoint for the Storefront.](/advanced/backend/endpoints/add-storefront)
|
||||
- [Check out the API reference for all available endpoints.](https://docs.medusajs.com/api/admin)
|
||||
@@ -173,4 +173,5 @@ const customer = await customerService.retrieve(id)
|
||||
|
||||
## What’s Next :rocket:
|
||||
|
||||
- [Check out the API reference for all available endpoints.](https://docs.medusajs.com/api/store)
|
||||
- [Learn how to add an endpoint for the Admin.](/advanced/backend/endpoints/add-admin)
|
||||
- [Check out the API reference for all available endpoints.](https://docs.medusajs.com/api/store)
|
||||
|
||||
107
docs/content/advanced/backend/services/create-service.md
Normal file
107
docs/content/advanced/backend/services/create-service.md
Normal file
@@ -0,0 +1,107 @@
|
||||
---
|
||||
|
||||
title: Create a Service
|
||||
|
||||
---
|
||||
|
||||
# Create a Service
|
||||
|
||||
In this document, you’ll learn how you can create a service and use it across your Medusa server just like any of the core services.
|
||||
|
||||
## Overview
|
||||
|
||||
Services in Medusa represent bundled helper methods that you want to use across your server. By convention, they represent a certain entity or functionality in your server.
|
||||
|
||||
For example, you can use Medusa’s `productService` to get the list of products, as well as perform other functionalities related to products. There’s also an `authService` that provides functionalities like authenticating customers and users.
|
||||
|
||||
Custom services reside in the `src/services` directory of your Medusa Server installation. Each service should be a class that extends the `BaseService` class from `medusa-interfaces`.
|
||||
|
||||
Each file you create in `src/services` should hold one service and export it.
|
||||
|
||||
The file name is important as it determines the name of the service when you need to use it elsewhere. The name of the service will be registered as the camel-case version of the file name + `Service` at the end of the name.
|
||||
|
||||
For example, if the file name is `hello.js`, the service will be registered as `helloService`. If the file name is `hello-world.js`, the service name will be registered as `helloWorldService`.
|
||||
|
||||
The registration name of the service is important, as you’ll be referring to it when you want to get access to the service using dependency injection or in routes.
|
||||
|
||||
## Implementation
|
||||
|
||||
To create a service, you should create a JavaScript file in `src/services` to hold the service. The name of the file should be the registration name of the service without `Service` as it will be appended to it by default.
|
||||
|
||||
For example, if you want to create a service `helloService`, create the file `hello.js` in `src/services` with the following content:
|
||||
|
||||
```js
|
||||
import { BaseService } from "medusa-interfaces";
|
||||
|
||||
class HelloService extends BaseService {
|
||||
getMessage() {
|
||||
return `Welcome to My Store!`
|
||||
}
|
||||
}
|
||||
|
||||
export default HelloService;
|
||||
```
|
||||
|
||||
## Service Constructor
|
||||
|
||||
As the service extends the `BaseService` class, all services in Medusa’s core, as well as all your custom services, will be available in your service’s constructor using dependency injection.
|
||||
|
||||
So, if you want your service to use another service, simply add it as part of your constructor’s dependencies and set it to a field inside your service’s class:
|
||||
|
||||
```js
|
||||
productService;
|
||||
|
||||
constructor({ productService }) {
|
||||
super();
|
||||
this.productService = productService;
|
||||
}
|
||||
```
|
||||
|
||||
Then, you can use that service anywhere in your custom service:
|
||||
|
||||
```js
|
||||
async getProductCount() {
|
||||
return await this.productService.count();
|
||||
}
|
||||
```
|
||||
|
||||
## Using your Custom Service
|
||||
|
||||
You can use your custom service throughout your Medusa server just like you would use any of the core services.
|
||||
|
||||
### In a Service
|
||||
|
||||
To use your custom service in another custom service, you can have easy access to it in the dependencies injected to the constructor of your service:
|
||||
|
||||
```js
|
||||
constructor({ helloService }) {
|
||||
super();
|
||||
this.helloService = helloService;
|
||||
}
|
||||
```
|
||||
|
||||
### In an Endpoint
|
||||
|
||||
To use your custom service in an endpoint, you can use `req.scope.resolve` passing it the service’s registration name:
|
||||
|
||||
```js
|
||||
const helloService = req.scope.resolve('helloService');
|
||||
|
||||
res.json({
|
||||
message: helloService.getMessage()
|
||||
})
|
||||
```
|
||||
|
||||
### In a Subscriber
|
||||
|
||||
To use your custom service in a subscriber, you can have easy access to it in the subscriber’s dependencies injected to the constructor of your subscriber:
|
||||
|
||||
```js
|
||||
constructor({ helloService, eventBusService }) {
|
||||
this.helloService = helloService;
|
||||
}
|
||||
```
|
||||
|
||||
## What’s Next 🚀
|
||||
|
||||
- [Learn How to Create an Endpoint.](/advanced/backend/endpoints/add-storefront)
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: homepage
|
||||
title: Introduction
|
||||
title: Overview
|
||||
description: 'What is Medusa?'
|
||||
slug: /
|
||||
hide_table_of_contents: true
|
||||
@@ -15,6 +15,14 @@ Medusa is an open-source Shopify alternative.
|
||||
|
||||
It provides you with the primitives to create amazing digital commerce experiences.
|
||||
|
||||
## Architecture overview
|
||||
|
||||
Medusa is composed of 3 components: The headless backend, the admin dashboard, and the storefront.
|
||||
|
||||
You can learn more about Medusa's architecture in [our introduction](/introduction).
|
||||
|
||||

|
||||
|
||||
<div class="container" style={{ padding: 0 }}>
|
||||
<div class="row is-multiline">
|
||||
<div class="col col--6">
|
||||
|
||||
@@ -6,7 +6,11 @@ title: "Deploying on Heroku"
|
||||
|
||||
This is a guide for deploying a Medusa project on Heroku. Heroku is at PaaS that allows you to easily deploy your applications in the cloud.
|
||||
|
||||
https://user-images.githubusercontent.com/59018053/154798681-37060f13-5248-47c5-97c5-81c06da301d4.mp4
|
||||
<div>
|
||||
<video width="100%" height="100%" playsinline autoplay muted controls>
|
||||
<source src="https://user-images.githubusercontent.com/59018053/154798681-37060f13-5248-47c5-97c5-81c06da301d4.mp4" type="video/mp4" />
|
||||
</video>
|
||||
</div>
|
||||
|
||||
> We assume, that you are currently running a local instance of Medusa. If not, check out our [Quickstart](https://docs.medusajs.com/quickstart/quick-start) or use `npx create-medusa-app` to set up your application in a matter of minutes. For the latter, see [this guide](https://docs.medusajs.com/how-to/create-medusa-app) for a small walkthrough.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ title: Making your store more powerful with Contentful
|
||||
|
||||
# Making your store more powerful with Contentful
|
||||
|
||||
In [part 1](https://docs.medusajs.com/how-to/headless-ecommerce-store-with-gatsby-contentful-medusa/) of this series you have set up [Medusa](https://medusa-commerce.com) with Contentful as your CMS system and added a Gatsby storefront. In this part you will get a further introduction to Contentful and learn how [`medusa-plugin-contentful`](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-contentful) can be leveraged to make your store more powerful. Apart from a front page, product pages and a checkout flow, most ecommerce stores also need miscalleneous pages like About and Contact pages. In this guide you will add a Rich Text content module to your Contentful space so that you can make this pages cool. You will also see how the content modules can be used to give your product pages more life.
|
||||
In [part 1](https://docs.medusajs.com/how-to/headless-ecommerce-store-with-gatsby-contentful-medusa/) of this series you have set up [Medusa](https://medusajs.com) with Contentful as your CMS system and added a Gatsby storefront. In this part you will get a further introduction to Contentful and learn how [`medusa-plugin-contentful`](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-contentful) can be leveraged to make your store more powerful. Apart from a front page, product pages and a checkout flow, most ecommerce stores also need miscalleneous pages like About and Contact pages. In this guide you will add a Rich Text content module to your Contentful space so that you can make this pages cool. You will also see how the content modules can be used to give your product pages more life.
|
||||
|
||||
What you will do in this guide:
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ In order to work with images in Medusa, you need a file service plugin responsib
|
||||
|
||||
### Before you start
|
||||
|
||||
At this point, you should have an instance of our store engine running. If not, we have a [full guide](https://docs.medusa-commerce.com/tutorial/set-up-your-development-environment) for setting up your local environment.
|
||||
At this point, you should have an instance of our store engine running. If not, we have a [full guide](https://docs.medusajs.com/tutorial/set-up-your-development-environment) for setting up your local environment.
|
||||
|
||||
### Set up MinIO
|
||||
|
||||
|
||||
29
docs/content/introduction.md
Normal file
29
docs/content/introduction.md
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
|
||||
title: Introduction
|
||||
|
||||
---
|
||||
|
||||
## Architecture overview
|
||||
|
||||
Medusa is composed of 3 components: The headless backend, the admin dashboard, and the storefront.
|
||||
|
||||

|
||||
|
||||
### Headless Backend
|
||||
|
||||
This is the main component that holds all the logic and data of the store. Your admin dashboard and storefront interact with the backend to retrieve, create, and modify data through REST APIs.
|
||||
|
||||
Your Medusa server will include all functionalities related to your store’s checkout workflow. That includes cart management, shipping and payment providers, user management, and more. It also allows you to configure your store including your store’s region, tax rules, discounts, gift cards, and more.
|
||||
|
||||
### Admin Dashboard
|
||||
|
||||
The admin dashboard is accessible by store operators. Store operators can use the admin dashboard to view, create, and modify data such as orders and products.
|
||||
|
||||
Medusa provides a beautiful [admin dashboard](https://demo.medusajs.com) that you can use right off the bat. Our admin dashboard provides a lot of functionalities to manage your store including Order management, product management, user management and more.
|
||||
|
||||
You can also create your own admin dashboard by utilizing the [Admin REST APIs](https://docs.medusajs.com/api/admin/auth).
|
||||
|
||||
### Storefront
|
||||
|
||||
Your customers use the Storefront to view products and make orders. Medusa provides 2 storefronts, one built with [Next.js](https://docs.medusajs.com/starters/nextjs-medusa-starter) and one with [Gatsby](https://docs.medusajs.com/starters/gatsby-medusa-starter). You are also free to create your own storefront using the [Storefront REST APIs](https://docs.medusajs.com/api/store/auth).
|
||||
@@ -35,9 +35,9 @@ Edit `src/pages/index.js` to see your site update in real-time!
|
||||
|
||||
**Learn more about Medusa**
|
||||
|
||||
- [Website](https://www.medusa-commerce.com/)
|
||||
- [Website](https://www.medusajs.com/)
|
||||
- [GitHub](https://github.com/medusajs)
|
||||
- [Documentation](https://docs.medusa-commerce.com/)
|
||||
- [Documentation](https://docs.medusajs.com/)
|
||||
|
||||
**Learn more about Gatsby**
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ Edit `src/pages/index.js` to see your site update in real-time!
|
||||
|
||||
**Learn more about Medusa**
|
||||
|
||||
- [Website](https://www.medusa-commerce.com/)
|
||||
- [Website](https://www.medusajs.com/)
|
||||
- [GitHub](https://github.com/medusajs)
|
||||
- [Documentation](https://docs.medusa-commerce.com/)
|
||||
- [Documentation](https://docs.medusajs.com/)
|
||||
|
||||
**Learn more about Next.js**
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ It is not important which editor you use as long as you feel comfortable working
|
||||
|
||||
As the final step in this part of the tutorial you should create a Medusa Cloud account. Medusa Cloud is the platform that works with Medusa; the platform is where you view and manage your store, but is also a key part of the development process as you will be linking your local project to the platform so that you can manage your store while in development.
|
||||
|
||||
[Sign up for Medusa Cloud](https://app.medusa-commerce.com) -->
|
||||
[Sign up for Medusa Cloud](https://app.medusajs.com) -->
|
||||
|
||||
## Summary
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ The `link` command will first check that you have authenticated your CLI which w
|
||||
|
||||
You should note that the `--develop` flag is optional for the `link` command. If provided it tells the CLI to start up your server after linking is completed; you may leave it out if you'd rather start your server separately.
|
||||
|
||||
> Note: For local linking to work you must make sure to have your CORS settings configured correctly. This is done by adding `https://app.medusa-commerce.com` to your `cors_admin` config in `medusa-config.js`.
|
||||
> Note: For local linking to work you must make sure to have your CORS settings configured correctly. This is done by adding `https://app.medusajs.com` to your `cors_admin` config in `medusa-config.js`.
|
||||
|
||||
> Note: If you change the port that your local server is running on you will have to run `medusa link` again. `medusa link` uses your `PORT` environment variable to specify where Medusa Cloud should look for your local server.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<p align="center">
|
||||
<a href="https://www.medusa-commerce.com">
|
||||
<a href="https://www.medusajs.com">
|
||||
<img alt="Medusa" src="https://user-images.githubusercontent.com/7554214/129161578-19b83dc8-fac5-4520-bd48-53cba676edd2.png" width="100" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@@ -14,6 +14,11 @@ module.exports = {
|
||||
{
|
||||
type: "doc",
|
||||
id: "homepage",
|
||||
label: "Overview",
|
||||
},
|
||||
{
|
||||
type: "doc",
|
||||
id: "introduction",
|
||||
label: "Introduction",
|
||||
},
|
||||
{
|
||||
@@ -115,6 +120,23 @@ module.exports = {
|
||||
id: "advanced/backend/endpoints/add-storefront",
|
||||
label: "Add Endpoint for Storefront"
|
||||
},
|
||||
{
|
||||
type: "doc",
|
||||
id: "advanced/backend/endpoints/add-admin",
|
||||
label: "Add Endpoint for Admin"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "category",
|
||||
label: 'Services',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
type: "doc",
|
||||
id: "advanced/backend/services/create-service",
|
||||
label: "Create a Service"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -9886,4 +9886,4 @@ yocto-queue@^0.1.0:
|
||||
zwitch@^1.0.0:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-1.0.5.tgz#d11d7381ffed16b742f6af7b3f223d5cd9fe9920"
|
||||
integrity sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==
|
||||
integrity sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==
|
||||
@@ -1,16 +1,15 @@
|
||||
<svg width="905" height="234" viewBox="0 0 905 234" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0)">
|
||||
<path d="M189.638 38.0267L136.744 7.55792C119.438 -2.43583 98.2313 -2.43583 80.925 7.55792L27.7875 38.0267C10.725 48.0204 0 66.5454 0 86.2892V147.47C0 167.458 10.725 185.739 27.7875 195.733L80.6812 226.445C97.9875 236.439 119.194 236.439 136.5 226.445L189.394 195.733C206.7 185.739 217.181 167.458 217.181 147.47V86.2892C217.669 66.5454 206.944 48.0204 189.638 38.0267ZM108.712 171.358C78.7312 171.358 54.3562 146.983 54.3562 117.002C54.3562 87.0204 78.7312 62.6454 108.712 62.6454C138.694 62.6454 163.312 87.0204 163.312 117.002C163.312 146.983 138.938 171.358 108.712 171.358Z" fill="#0A3149"/>
|
||||
<path d="M398.808 55.3289H433.176V174.766H412.458V73.3664L379.308 174.766H357.614L324.464 74.5852V174.766H303.745V55.3289H338.358L368.583 151.123L398.808 55.3289Z" fill="#0A3149"/>
|
||||
<path d="M537.501 147.712C532.626 165.749 517.27 176.962 496.064 176.962C469.495 176.962 452.433 158.924 452.433 131.868C452.433 104.812 469.495 86.774 496.552 86.774C526.533 86.774 542.133 109.199 533.845 137.23H473.151C474.858 151.368 482.658 159.655 496.308 159.655C505.814 159.655 513.37 155.268 516.295 147.468H537.501V147.712ZM473.639 123.58H515.564C516.783 111.393 509.714 103.349 496.308 103.349C483.633 103.349 475.589 110.418 473.639 123.58Z" fill="#0A3149"/>
|
||||
<path d="M615.989 55.3293H635.489V174.767H615.989V162.092C609.408 171.598 599.414 177.204 586.983 177.204C564.558 177.204 548.47 159.167 548.47 132.111C548.47 105.054 564.07 87.0168 586.983 87.0168C599.414 87.0168 609.408 92.3793 615.989 102.129V55.3293ZM616.72 132.111C616.72 115.292 607.214 104.079 592.833 104.079C578.208 104.079 568.701 115.292 568.701 132.111C568.701 148.929 578.208 160.142 592.833 160.142C607.214 159.898 616.72 148.929 616.72 132.111Z" fill="#0A3149"/>
|
||||
<path d="M707.639 89.4553H727.139V174.768H707.639V159.412C701.545 170.868 692.039 176.718 680.095 176.718C656.451 176.718 652.552 153.074 652.552 137.962V89.2115H672.052V137.718C672.052 148.93 674.733 159.655 686.92 159.655C699.595 159.655 707.639 148.443 707.639 132.599V89.4553Z" fill="#0A3149"/>
|
||||
<path d="M741.52 144.055H760.289C759.07 154.537 766.87 161.362 780.277 161.362C790.758 161.362 797.583 157.218 797.583 151.124C797.583 134.062 742.739 146.249 742.739 114.318C742.739 97.2553 758.583 86.774 779.302 86.774C802.214 86.774 818.789 99.449 815.133 118.949H796.12C798.558 109.199 790.758 102.618 779.058 102.618C769.064 102.618 762.726 107.005 762.726 113.099C762.726 130.405 817.814 117.243 817.814 149.662C817.814 166.968 802.214 176.962 780.033 176.962C755.901 176.962 740.058 164.774 741.52 144.055Z" fill="#0A3149"/>
|
||||
<path d="M905.077 126.261V174.767H887.039V159.898C880.702 170.867 870.22 177.204 856.327 177.204C838.289 177.204 827.077 166.723 827.077 151.854C827.077 134.548 842.189 124.311 866.077 124.311C872.658 124.311 879.483 125.042 885.577 126.504C885.577 113.586 880.945 104.079 867.295 104.079C857.058 104.079 850.72 109.198 852.67 118.704H832.927C828.295 99.6918 845.114 87.0168 867.295 87.0168C892.402 87.0168 905.077 102.373 905.077 126.261ZM886.308 141.129C880.702 139.179 873.877 138.204 867.783 138.204C853.889 138.204 847.064 143.323 847.064 151.123C847.064 157.948 852.183 161.604 860.47 161.604C872.902 161.604 883.139 153.561 886.308 141.129Z" fill="#0A3149"/>
|
||||
</g>
|
||||
<svg width="204" height="49" viewBox="0 0 204 49" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M81.4167 35.7292H76.8178V23.765C76.8178 22.4311 76.4922 21.383 75.841 20.6208C75.1898 19.8314 74.2945 19.4366 73.1549 19.4366C71.8526 19.4366 70.8351 19.8722 70.1025 20.7433C69.3971 21.6144 69.0444 22.8122 69.0444 24.3367V35.7292H64.4048V15.7208H68.963V17.4766C70.2111 15.9794 71.934 15.2308 74.1317 15.2308C76.6007 15.2308 78.4592 16.1019 79.7073 17.8441C81.2539 16.1019 83.3295 15.2308 85.9342 15.2308C88.5389 15.2308 90.5059 15.993 91.8354 17.5175C93.192 19.0147 93.8703 21.2061 93.8703 24.0916V35.7292H89.2307V23.765C89.2307 22.4311 88.9051 21.383 88.254 20.6208C87.6028 19.8314 86.7074 19.4366 85.5679 19.4366C84.2655 19.4366 83.2481 19.8858 82.5155 20.7841C81.7829 21.6553 81.4167 22.8394 81.4167 24.3367V35.7292Z" fill="#111827"/>
|
||||
<path d="M116.441 25.48L116.4 27.1133H102.766C102.875 28.6105 103.404 29.7947 104.354 30.6658C105.303 31.5369 106.524 31.9725 108.016 31.9725C110.16 31.9725 111.869 31.0333 113.144 29.155L116.278 32.095C114.162 34.8172 111.408 36.1783 108.016 36.1783C105.005 36.1783 102.59 35.2255 100.772 33.32C98.9272 31.3872 98.0047 28.8964 98.0047 25.8475C98.0047 22.8803 98.8458 20.3622 100.528 18.2933C102.237 16.2516 104.503 15.2308 107.325 15.2308C110.336 15.2308 112.602 16.238 114.121 18.2525C115.668 20.2669 116.441 22.6761 116.441 25.48ZM107.365 19.4775C106.199 19.4775 105.235 19.845 104.476 20.58C103.743 21.315 103.255 22.2542 103.011 23.3975H111.517C111.489 22.2814 111.123 21.3558 110.418 20.6208C109.712 19.8586 108.695 19.4775 107.365 19.4775Z" fill="#111827"/>
|
||||
<path d="M130.108 15.2308C132.332 15.2308 134.191 15.8841 135.683 17.1908V7.10498H140.323V35.7292H135.765V33.9325C134.354 35.4297 132.468 36.1783 130.108 36.1783C127.286 36.1783 124.953 35.1983 123.108 33.2383C121.29 31.2511 120.381 28.7467 120.381 25.725C120.381 22.7033 121.29 20.1989 123.108 18.2116C124.925 16.2244 127.259 15.2308 130.108 15.2308ZM134.34 21.1516C133.391 19.9539 132.088 19.355 130.433 19.355C128.778 19.355 127.476 19.9539 126.526 21.1516C125.577 22.3494 125.102 23.8739 125.102 25.725C125.102 27.5761 125.577 29.1005 126.526 30.2983C127.476 31.4961 128.778 32.095 130.433 32.095C132.088 32.095 133.391 31.4961 134.34 30.2983C135.29 29.1005 135.765 27.5761 135.765 25.725C135.765 23.8739 135.29 22.3494 134.34 21.1516Z" fill="#111827"/>
|
||||
<path d="M145.431 15.7208H150.071V27.685C150.071 29.0189 150.396 30.0805 151.048 30.87C151.699 31.6322 152.621 32.0133 153.815 32.0133C155.09 32.0133 156.094 31.5642 156.827 30.6658C157.586 29.7403 157.966 28.5153 157.966 26.9908V15.7208H162.606V35.7292H158.048V34.0958C156.772 35.4842 155.05 36.1783 152.879 36.1783C150.6 36.1783 148.782 35.4025 147.425 33.8508C146.096 32.2719 145.431 30.1078 145.431 27.3583V15.7208Z" fill="#111827"/>
|
||||
<path d="M176.355 28.175L173.709 27.5217C169.667 26.5689 167.645 24.4592 167.645 21.1925C167.645 19.3958 168.324 17.953 169.68 16.8642C171.037 15.7753 172.787 15.2308 174.93 15.2308C177.806 15.2308 180.316 16.3469 182.46 18.5791L179.489 21.7642C178.268 20.0764 176.708 19.2325 174.808 19.2325C173.994 19.2325 173.33 19.423 172.814 19.8041C172.326 20.158 172.082 20.5936 172.082 21.1108C172.082 22.0364 172.733 22.6625 174.035 22.9892L177.169 23.7242C181.239 24.6497 183.274 26.7322 183.274 29.9717C183.274 31.8228 182.568 33.32 181.157 34.4633C179.774 35.6067 177.847 36.1783 175.378 36.1783C171.905 36.1783 169.151 34.8853 167.116 32.2992L170.047 29.2775C171.512 31.2103 173.411 32.1767 175.744 32.1767C177.779 32.1767 178.797 31.4961 178.797 30.135C178.797 29.2639 177.983 28.6105 176.355 28.175Z" fill="#111827"/>
|
||||
<path d="M193.271 36.1783C191.345 36.1783 189.744 35.6339 188.469 34.545C187.194 33.4289 186.556 31.9453 186.556 30.0942C186.556 27.9708 187.316 26.3239 188.835 25.1533C190.355 23.9828 192.362 23.3975 194.859 23.3975C196.107 23.3975 197.45 23.6289 198.888 24.0916V22.7442C198.888 21.7642 198.521 20.9747 197.789 20.3758C197.056 19.7497 196.12 19.4366 194.981 19.4366C192.892 19.4366 191.318 20.403 190.26 22.3358L187.126 19.3958C187.858 18.0619 188.93 17.0411 190.341 16.3333C191.779 15.5983 193.339 15.2308 195.021 15.2308C197.653 15.2308 199.729 15.8841 201.248 17.1908C202.768 18.4975 203.527 20.3622 203.527 22.785V35.7292H198.969V34.1775C197.477 35.5114 195.578 36.1783 193.271 36.1783ZM191.196 29.7675C191.196 30.448 191.453 31.0061 191.969 31.4417C192.512 31.8772 193.258 32.095 194.207 32.095C196.161 32.095 197.721 31.5233 198.888 30.38V28.0933C197.423 27.5489 196.039 27.2767 194.736 27.2767C193.651 27.2767 192.783 27.4944 192.132 27.93C191.508 28.3655 191.196 28.978 191.196 29.7675Z" fill="#111827"/>
|
||||
<path d="M39.5317 7.95388L28.5055 1.57035C24.8979 -0.52345 20.4772 -0.52345 16.8696 1.57035L5.79257 7.95388C2.23573 10.0477 0 13.9289 0 18.0654V30.8835C0 35.0711 2.23573 38.9013 5.79257 40.9951L16.8188 47.4297C20.4264 49.5234 24.8471 49.5234 28.4547 47.4297L39.4809 40.9951C43.0886 38.9013 45.2735 35.0711 45.2735 30.8835V18.0654C45.3751 13.9289 43.1394 10.0477 39.5317 7.95388ZM22.6621 35.8882C16.4123 35.8882 11.3311 30.7814 11.3311 24.5C11.3311 18.2186 16.4123 13.1118 22.6621 13.1118C28.912 13.1118 34.044 18.2186 34.044 24.5C34.044 30.7814 28.9628 35.8882 22.6621 35.8882Z" fill="url(#paint0_linear_107_5)"/>
|
||||
<defs>
|
||||
<clipPath id="clip0">
|
||||
<rect width="904.8" height="234" fill="white"/>
|
||||
</clipPath>
|
||||
<linearGradient id="paint0_linear_107_5" x1="-1.75721e-09" y1="24.5" x2="45.2768" y2="24.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#7C53FF"/>
|
||||
<stop offset="1" stop-color="#F796FF"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 5.4 KiB |
@@ -1,16 +1,17 @@
|
||||
import { Box, Flex, Heading, Text } from "theme-ui"
|
||||
import React, { useContext, useEffect, useRef } from "react"
|
||||
import Markdown from "react-markdown"
|
||||
import { Flex, Text, Box, Heading } from "theme-ui"
|
||||
import { convertToKebabCase } from "../../utils/convert-to-kebab-case"
|
||||
import Parameters from "./parameters"
|
||||
import Route from "./route"
|
||||
import JsonContainer from "./json-container"
|
||||
|
||||
import Description from "./description"
|
||||
import ResponsiveContainer from "./responsive-container"
|
||||
import { formatMethodParams } from "../../utils/format-parameters"
|
||||
import useInView from "../../hooks/use-in-view"
|
||||
import JsonContainer from "./json-container"
|
||||
import Markdown from "react-markdown"
|
||||
import NavigationContext from "../../context/navigation-context"
|
||||
import Parameters from "./parameters"
|
||||
import ResponsiveContainer from "./responsive-container"
|
||||
import Route from "./route"
|
||||
import { convertToKebabCase } from "../../utils/convert-to-kebab-case"
|
||||
import { formatMethodParams } from "../../utils/format-parameters"
|
||||
import { formatRoute } from "../../utils/format-route"
|
||||
import useInView from "../../hooks/use-in-view"
|
||||
|
||||
const Method = ({ data, section, pathname, api }) => {
|
||||
const { parameters, requestBody, description, method, summary } = data
|
||||
@@ -86,7 +87,7 @@ const Method = ({ data, section, pathname, api }) => {
|
||||
}
|
||||
|
||||
const getCurlJson = (properties, prefix, bodyParameters) => {
|
||||
if (!properties[0]) {
|
||||
if (!properties[0] || !jsonResponse) {
|
||||
return
|
||||
}
|
||||
const jsonObject = JSON.parse(jsonResponse)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 15 KiB |
Reference in New Issue
Block a user