Skip to content

Latest commit

 

History

History
145 lines (107 loc) · 3.46 KB

migrate-to-express-or-fastify-package.md

File metadata and controls

145 lines (107 loc) · 3.46 KB

Migrating to @nestjs-shopify/express or @nestjs-shopify/fastify

The @nestjs-shopify/core package has been deprecated in favor of @nestjs-shopify/express or @nestjs-shopify/fastify. The new packages are designed to work with the respective web frameworks and provide a more flexible and powerful API.

To migrate your NestJS app to use the new adaptable version, follow this guide.

Table of Contents

Express package

Add the new @nestjs-shopify/express package to your project:

npm install @nestjs-shopify/express

or using Yarn:

yarn add @nestjs-shopify/express

You will have to replace all occurences to ShopifyCoreModule with ShopifyExpressModule in your application root module:

// app.module.ts
import { Module } from '@nestjs/common';
-import { ShopifyCoreModule } from '@nestjs-shopify/core';
+import { ShopifyExpressModule } from '@nestjs-shopify/express';

@Module({
  imports: [
-    ShopifyCoreModule.forRoot({
+    ShopifyExpressModule.forRoot({
      apiKey: 'foo',
      apiSecret

Fastify package

Add the new @nestjs-shopify/fastify package to your project:

npm install @nestjs-shopify/fastify

or using Yarn:

yarn add @nestjs-shopify/fastify

You will have to replace all occurences to ShopifyCoreModule with ShopifyFastifyModule in your application root module:

// app.module.ts
import { Module } from '@nestjs/common';
-import { ShopifyCoreModule } from '@nestjs-shopify/core';
+import { ShopifyFastifyModule } from '@nestjs-shopify/fastify';

@Module({
  imports: [
-    ShopifyCoreModule.forRoot({
+    ShopifyFastifyModule.forRoot({
      apiKey: 'foo',
      apiSecret

Changes to CSP

The ShopifyCspMiddleware has been moved to a separate package. If you were using it in your application, you will have to install the new package:

npm install @nestjs-shopify/common

or using Yarn:

yarn add @nestjs-shopify/common

You will have to replace all imports to ShopifyCspMiddleware:

// app.module.ts
import { Module } from '@nestjs/common';
-import { ShopifyCspMiddleware } from '@nestjs-shopify/core';
+import { ShopifyCspMiddleware } from '@nestjs-shopify/common';

Changes to HMAC validation

The ShopifyHmacGuard has been moved to the @nestjs-shopify/common package as well. If you were using it in your application, you will have to install the new package:

npm install @nestjs-shopify/common

or using Yarn:

yarn add @nestjs-shopify/common

You will have to replace all imports to ShopifyHmacGuard:

// app.controller.ts
import { Controller, Get, UseGuards } from '@nestjs/common';
-import { ShopifyHmacGuard } from '@nestjs-shopify/core';
+import { ShopifyHmacGuard } from '@nestjs-shopify/common';

@Controller('products')
export class ProductController {
  @Get()
  @UseGuards(ShopifyHmacGuard)
  getProducts() {
    // ...
  }
}

Or if you were using the @ShopifyHmac decorator:

// product.controller.ts
import { Controller, Get } from '@nestjs/common';
-import { ShopifyHmac, ShopifyHmacType } from '@nestjs-shopify/core';
+import { ShopifyHmac, ShopifyHmacType } from '@nestjs-shopify/common';

@Controller('products')
export class ProductController {
  @Get()
  @ShopifyHmac(HmacType.Query)
  getProducts() {
    // ...
  }
}