Giter Site home page Giter Site logo

nailyjs / nest-apple-app-store Goto Github PK

View Code? Open in Web Editor NEW
2.0 0.0 0.0 386 KB

🍎 Apple App Store Node.js Server SDK for Nest.js Nest.jsη‰ˆθ‹Ήζžœ App Store Node.js服劑端SDK

Home Page: https://github.com/nailyjs/nest-apple-app-store

License: Apache License 2.0

JavaScript 15.86% Shell 1.44% TypeScript 82.70%
app-store app-store-server-api apple nest nest-module nestjs nestjs-backend nestjs-module

nest-apple-app-store's Introduction

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

nest-apple-app-store's People

Contributors

groupguanfang avatar

Stargazers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.