open-index/open-npm huggingface dataset:
npm package: @nestjs-shopify/common
Description: [@shopify/shopify-node-api](https://github.com/Shopify/shopify-node-api) to setup your Shopify context in a NestJS application. This library was generated with [Nx](https://nx.dev).
Latest version: 2.1.0

# @nestjs-shopify/common

[@shopify/shopify-node-api](https://github.com/Shopify/shopify-node-api) to setup your Shopify context in a NestJS application.
This library was generated with [Nx](https://nx.dev).

# Installation

```
npm i @shopify/shopify-api @nestjs-shopify/core @nestjs-shopify/express @nestjs-shopify/common
```

or using Yarn:

```
yarn add @shopify/shopify-api @nestjs-shopify/core @nestjs-shopify/express @nestjs-shopify/common
```

# Usage

Run `nx test common` to execute the unit tests via [Jest](https://jestjs.io).

# CSP middleware

The library provides a CSP middleware that you can use to protect your application from XSS attacks. The middleware is not applied by default. To make use of this middleware, add the following to your application root module:

```ts
// app.module.ts
import { ShopifyCspMiddleware } from '@nestjs-shopify/common';
import { ShopifyExpressModule } from '@nestjs-shopify/express';
import { Module, NestModule } from '@nestjs/common';

@Module({
  imports: [
    ShopifyExpressModule.forRoot({ ... }),
    // ...
  ],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    // Apply the middleware to all routes
    consumer.apply(ShopifyCspMiddleware).forRoutes('*');

    // Or apply the middleware to specific routes
    consumer
      .apply(ShopifyCspMiddleware)
      .exclude('cats')
      .forRoutes({ path: 'ab*cd', method: RequestMethod.ALL });
  }
}
```
npm package: @nestjs-shopify/graphql
Description: A NestJS module for exposing a Shopify GraphQL Admin API proxy. The `ShopifyGraphqlProxyModule` allows you to expose the GraphQL Admin API without having to pass in an `X-Shopify-Access-Token`. The module automatically provides everything necessary to cal
Latest version: 6.0.1

# @nestjs-shopify/graphql

A NestJS module for exposing a Shopify GraphQL Admin API proxy. The `ShopifyGraphqlProxyModule` allows you to expose the GraphQL Admin API without having to pass in an `X-Shopify-Access-Token`. The module automatically provides everything necessary to call the Shopify GraphQL Admin API. Uses [`@shopify/shopify-api`](https://github.com/shopify/shopify-node-api) under the hood.

# Installation

Install required dependencies and this package using NPM:

```
npm i @shopify/shopify-api @nestjs-shopify/core @shopify-nestjs/express @nestjs-shopify/auth @nestjs-shopify/graphql
```

or using Yarn:

```
yarn add @shopify/shopify-api @nestjs-shopify/core @shopify-nestjs/express @nestjs-shopify/auth @nestjs-shopify/graphql
```

> **Note**
>
> Install `@nestjs-shopify/express` if you are using Express, or `@nestjs-shopify/fastify` if you are using Fastify.

# Usage

From your application root module, import the `ShopifyGraphqlProxyModule`:

```ts
// app.module.ts
import { ShopifyAuthModule } from '@nestjs-shopify/auth';
import { ShopifyExpressModule } from '@nestjs-shopify/express';
import { ShopifyGraphqlProxyModule } from '@nestjs-shopify/graphql';

@Module({
  imports: [
    ShopifyExpressModule.forRoot({
      apiKey: 'foo',
      apiSecret: 'bar',
      apiVersion: ApiVersion.Unstable,
      hostName: 'localhost:8081',
      isEmbeddedApp: true,
      scopes: ['test_scope'],
    }),
    ShopifyAuthModule.forRootOnline({
      basePath: 'user',
      returnHeaders: true,
    }),
    ShopifyGraphqlProxyModule,
  ],
})
export class AppModule {}
```

This will expose the `/graphql` endpoint.

Make sure to setup online session authentication using `ShopifyAuthModule` with `forRootOnline` or `forRootAsyncOnline`. The Admin GraphQL API proxy only works with online session tokens. Not with offline tokens.