diff --git a/docs/content/development/endpoints/example-logged-in-user.md b/docs/content/development/endpoints/example-logged-in-user.md index a639188839..04b302e00f 100644 --- a/docs/content/development/endpoints/example-logged-in-user.md +++ b/docs/content/development/endpoints/example-logged-in-user.md @@ -13,9 +13,9 @@ This documentation does not explain the basics of [middlewares](./add-middleware ## Step 1: Create the Middleware -Create the file `src/api/middlewareds/logged-in-user.ts` with the following content: +Create the file `src/api/middlewares/logged-in-user.ts` with the following content: -```ts title=src/api/middlewareds/logged-in-user.ts +```ts title=src/api/middlewares/logged-in-user.ts import { User, UserService } from "@medusajs/medusa" export async function registerLoggedInUser(req, res, next) { @@ -43,7 +43,13 @@ This retrieves the ID of the current user to retrieve an instance of it, then re ## Step 2: Apply Middleware on Endpoint -Create the file `src/api/routes/create-product.ts` with the following content: +If you don't have the `cors` package installed, make sure to install it first: + +```bash npm2yarn +npm install cors +``` + +Then, create the file `src/api/routes/create-product.ts` with the following content: ```ts title=src/api/routes/create-product.ts import cors from "cors" @@ -91,7 +97,7 @@ Create the file `src/api/index.ts` with the following content: import configLoader from "@medusajs/medusa/dist/loaders/config" import createProductRouter from "./routes/create-product" -export default async function (rootDirectory: string) { +export default function (rootDirectory: string) { const config = await configLoader(rootDirectory) const adminCors = { diff --git a/docs/content/development/entities/migrations/create.md b/docs/content/development/entities/migrations/create.md index 362580995f..49a33d439a 100644 --- a/docs/content/development/entities/migrations/create.md +++ b/docs/content/development/entities/migrations/create.md @@ -12,7 +12,7 @@ In this document, you’ll learn how to create a [Migration](./overview.mdx) usi To create a migration that makes changes to your Medusa schema, run the following command: ```bash -npx typeorm migration:create -n UserChanged --dir src/migrations +npx typeorm migration:create src/migrations/UserChanged ``` This will create the migration file in the path you specify. You can use this without the need to install Typeorm's CLI tool. You can then go ahead and make changes to it as necessary. diff --git a/docs/content/development/services/extend-service.md b/docs/content/development/services/extend-service.md index a40a176771..78833e7492 100644 --- a/docs/content/development/services/extend-service.md +++ b/docs/content/development/services/extend-service.md @@ -57,7 +57,7 @@ import { class ProductService extends MedusaProductService { // The default life time for a core service is SINGLETON - static LIFE_TIME = LifeTime.SCOPED + static LIFE_TIME = Lifetime.SCOPED // ... } diff --git a/www/docs/docusaurus.config.js b/www/docs/docusaurus.config.js index 53b7e8ce9c..eff1164065 100644 --- a/www/docs/docusaurus.config.js +++ b/www/docs/docusaurus.config.js @@ -1,14 +1,14 @@ -require('dotenv').config(); +require("dotenv").config() const path = require("path") const fs = require("fs") const docsPath = path.join(__dirname, "../../docs/content") const apisPath = path.join(__dirname, "../../docs/api") -const reverseSidebar = require('./src/utils/reverseSidebar') +const reverseSidebar = require("./src/utils/reverseSidebar") const algoliaAppId = process.env.ALGOLIA_APP_ID || "temp" const algoliaApiKey = process.env.ALGOLIA_API_KEY || "temp" -const announcementBar = JSON.parse(fs.readFileSync('./announcement.json')) +const announcementBar = JSON.parse(fs.readFileSync("./announcement.json")) /** @type {import('@docusaurus/types').DocusaurusConfig} */ const config = { @@ -25,15 +25,15 @@ const config = { [ "docusaurus-plugin-segment", { - apiKey: process.env.SEGMENT_API_KEY || "temp" - } + apiKey: process.env.SEGMENT_API_KEY || "temp", + }, ], require.resolve("docusaurus-plugin-image-zoom"), ], themeConfig: { - image: 'img/docs-banner.jpg', + image: "img/docs-banner.jpg", colorMode: { - defaultMode: 'light', + defaultMode: "light", disableSwitch: false, respectPrefersColorScheme: true, }, @@ -43,7 +43,7 @@ const config = { placeholder: "Search docs...", appId: algoliaAppId, contextualSearch: false, - externalUrlRegex: "https://medusajs.com" + externalUrlRegex: "https://medusajs.com", }, prism: { defaultLanguage: "js", @@ -51,46 +51,46 @@ const config = { theme: require("./src/themes/medusaDocs"), }, zoom: { - selector: '.markdown :not(.no-zoom-img) > img:not(.no-zoom-img)' + selector: ".markdown :not(.no-zoom-img) > img:not(.no-zoom-img)", }, navbar: { hideOnScroll: false, logo: { alt: "Medusa", src: "img/logo.png", - srcDark: "img/logo-dark.png" + srcDark: "img/logo-dark.png", }, items: [ { - type: 'search', - position: 'left', + type: "search", + position: "left", }, { type: "docSidebar", sidebarId: "homepage", label: "Docs", - position: "right" + position: "right", }, { type: "docSidebar", sidebarId: "userGuideSidebar", label: "User Guide", - position: "right" + position: "right", }, { href: "/api/store", label: "Store API", prependBaseUrlToHref: true, - target: '_blank', - position: "right" + target: "_blank", + position: "right", }, { href: "/api/admin", label: "Admin API", prependBaseUrlToHref: true, - target: '_blank', - position: "right" - } + target: "_blank", + position: "right", + }, ], }, navbarActions: [ @@ -98,51 +98,49 @@ const config = { type: "link", href: "https://github.com/medusajs/medusa/issues/new?assignees=&labels=type%3A+docs&template=docs.yml", title: "Report an Issue", - icon: "report" - } + icon: "report", + }, ], footer: { copyright: `© ${new Date().getFullYear()} Medusa, Inc. All rights reserved.`, }, socialLinks: [ { - type: 'discord', - href: 'https://discord.gg/medusajs' + type: "discord", + href: "https://discord.gg/medusajs", }, { - type: 'twitter', - href: 'https://twitter.com/medusajs' + type: "twitter", + href: "https://twitter.com/medusajs", }, { - type: 'linkedin', - href: 'https://www.linkedin.com/company/medusajs' + type: "linkedin", + href: "https://www.linkedin.com/company/medusajs", }, { - type: 'github', - href: 'https://github.com/medusajs/medusa' - } + type: "github", + href: "https://github.com/medusajs/medusa", + }, ], - reportCodeLinkPrefix: 'https://github.com/medusajs/medusa/issues/new?assignees=&labels=type%3A+docs&template=docs.yml', + reportCodeLinkPrefix: + "https://github.com/medusajs/medusa/issues/new?assignees=&labels=type%3A+docs&template=docs.yml", footerFeedback: { - event: 'survey' + event: "survey", }, docs: { sidebar: { - autoCollapseCategories: true - } + autoCollapseCategories: true, + }, }, cloudinaryConfig: { cloudName: process.env.CLOUDINARY_CLOUD_NAME || "", - flags: [ - 'fl_lossy', - 'f_auto' - ], + flags: ["fl_lossy", "f_auto"], resize: { - action: 'pad', - aspectRatio: '16:9' + action: "pad", + aspectRatio: "16:9", }, - roundCorners: 16 - } + roundCorners: 16, + }, }, presets: [ [ @@ -150,50 +148,54 @@ const config = { { docs: { sidebarPath: require.resolve("./sidebars.js"), - editUrl: "https://github.com/medusajs/medusa/edit/master/docs/content", + editUrl: + "https://github.com/medusajs/medusa/edit/develop/docs/content", path: docsPath, routeBasePath: "/", remarkPlugins: [ - [require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}], + [require("@docusaurus/remark-plugin-npm2yarn"), { sync: true }], ], showLastUpdateTime: true, // breadcrumbs: false, - async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) { - const sidebarItems = await defaultSidebarItemsGenerator(args); - return reverseSidebar(sidebarItems, args.item); + async sidebarItemsGenerator({ + defaultSidebarItemsGenerator, + ...args + }) { + const sidebarItems = await defaultSidebarItemsGenerator(args) + return reverseSidebar(sidebarItems, args.item) }, }, theme: { - customCss: require.resolve("./src/css/custom.css") + customCss: require.resolve("./src/css/custom.css"), }, gtag: { - trackingID: 'G-S7G7X3JYS3', + trackingID: "G-S7G7X3JYS3", }, }, ], [ - 'redocusaurus', + "redocusaurus", { // Plugin Options for loading OpenAPI files specs: [ { - spec: path.join(apisPath, 'store/openapi.yaml'), - route: '/api/store', + spec: path.join(apisPath, "store/openapi.yaml"), + route: "/api/store", layout: { - noFooter: true - } + noFooter: true, + }, }, { - spec: path.join(apisPath, 'admin/openapi.yaml'), - route: '/api/admin', + spec: path.join(apisPath, "admin/openapi.yaml"), + route: "/api/admin", layout: { - noFooter: true - } - } + noFooter: true, + }, + }, ], // Theme Options for modifying how redoc renders them theme: { - primaryColorDark: '#161618', + primaryColorDark: "#161618", options: { disableSearch: true, nativeScrollbars: true, @@ -203,14 +205,14 @@ const config = { generatedPayloadSamplesMaxDepth: 4, showObjectSchemaExamples: true, requiredPropsFirst: true, - hideRequestPayloadSample: true + hideRequestPayloadSample: true, }, theme: { sidebar: { - width: '250px' - } - } - } + width: "250px", + }, + }, + }, }, ], ],