Skip to content

๐ŸŽ Apple App Store Node.js Server SDK for Nest.js Nest.js็‰ˆ่‹นๆžœ App Store Node.jsๆœๅŠก็ซฏSDK

License

Notifications You must be signed in to change notification settings

nailyjs/nest-apple-app-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Apple App Store Server SDK for Nest.js ๐ŸŽ

ไธญๆ–‡ | English

Introduction ๐Ÿ“–

This is a Nest.js SDK for Apple App Store Server API. It is based on apple-app-store-api.

It is a Nest.js module that can be easily integrated into Nest.js projects.

Install ๐Ÿ“ฆ

npmใ€yarnใ€pnpm are all supported. Recommend pnpm.

pnpm add @nailyjs.nest.modules/app-store @apple/app-store-server-library

Usage ๐Ÿ“š

Basic Usage ๐Ÿ’ผ

import { Module } from "@nestjs/common";
import { AppleAppStoreModule } from "@nailyjs.nest.modules/app-store";

@Module({
  imports: [
    AppleAppStoreModule.register({
      // If true, the module can be used across all modules.
      global: true,
      clients: {
        provide: APP_STORE_SERVER_API_CLIENT,
        signingKey: "",
        issuerId: "",
        bundleId: "",
        keyId: "",
        environment: Environment.SANDBOX,
      },
    }),
  ],
})
export class AppModule {}

In your service, you can directly inject the AppStoreServerAPIClient instance.

import { Injectable } from "@nestjs/common";
import { AppStoreServerAPIClient } from "@apple/app-store-server-library";

@Injectable()
export class AppStoreService {
  constructor(private readonly appStoreServerAPIClient: AppStoreServerAPIClient) {}

  // ...
}

AppStoreServerAPIClient is imported from official package @apple/app-store-server-library.

Async Usage ๐Ÿš€

import { Module } from "@nestjs/common";
import { AppleAppStoreModule } from "@nailyjs.nest.modules/app-store";
import { Environment } from "@apple/app-store-server-library";

@Module({
  imports: [
    AppleAppStoreModule.registerAsync({
      // If true, the module can be used across all modules.
      global: true,
      clients: {
        inject: [],
        useFactory: () => {
          return {
            signingKey: "",
            issuerId: "",
            bundleId: "",
            keyId: "",
            environment: Environment.SANDBOX,
          };
        },
      },
    }),
  ],
})
export class AppModule {}

Multiple Clients ๐Ÿ”—

Also can use multiple async clients. The following example shows how to use multiple general clients.

import { Module } from "@nestjs/common";
import { AppleAppStoreModule } from "@nailyjs.nest.modules/app-store";
import { Environment } from "@apple/app-store-server-library";

export const APP_STORE_SERVER_API_CLIENT_ONE = Symbol("APP_STORE_SERVER_API_CLIENT_ONE");
export const APP_STORE_SERVER_API_CLIENT_TWO = Symbol("APP_STORE_SERVER_API_CLIENT_TWO");

@Module({
  imports: [
    AppleAppStoreModule.register({
      // If true, the module can be used across all modules.
      global: true,
      clients: [
        {
          provide: APP_STORE_SERVER_API_CLIENT_ONE,
          signingKey: "",
          issuerId: "",
          bundleId: "",
          keyId: "",
          environment: Environment.SANDBOX,
        },
        {
          provide: APP_STORE_SERVER_API_CLIENT_TWO,
          signingKey: "",
          issuerId: "",
          bundleId: "",
          keyId: "",
          environment: Environment.PRODUCTION,
        },
      ],
    }),
  ],
})
export class AppModule {}

In your service, you can inject the exported APP_STORE_SERVER_API_CLIENT_ONE or APP_STORE_SERVER_API_CLIENT_TWO symbol.

import { Injectable } from "@nestjs/common";
import { AppStoreServerAPIClient } from "@apple/app-store-server-library";
import { APP_STORE_SERVER_API_CLIENT_ONE } from "./app.module";

@Injectable()
export class AppStoreService {
  constructor(
    @Inject(APP_STORE_SERVER_API_CLIENT_ONE)
    private readonly appStoreServerAPIClientOne: AppStoreServerAPIClient,
    @Inject(APP_STORE_SERVER_API_CLIENT_TWO)
    private readonly appStoreServerAPIClientTwo: AppStoreServerAPIClient,
  ) {}

  // ...
}

Author ๐Ÿ‘จโ€๐Ÿ’ป

Zero

Donate โ˜•๏ธ

If you find this project useful, you can buy author a glass of coffee ๐Ÿฅฐ

wechat alipay

About

๐ŸŽ Apple App Store Node.js Server SDK for Nest.js Nest.js็‰ˆ่‹นๆžœ App Store Node.jsๆœๅŠก็ซฏSDK

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published