npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nailyjs.nest.modules/upyun

v1.0.3

Published

☁️ Nest.js upyun module

Downloads

3

Readme

☁️ Upyun SDK for nest.js

A upyun sdk for nest.js.

Installation

pnpm i @nailyjs.nest.modules/upyun

Usage

import { Module } from '@nestjs/common';
import { UpyunModule } from '@nailyjs.nest.modules/upyun';

@Module({
  imports: [
    UpyunModule.forRoot({
      operator: 'operator',
      password: 'password',
      bucket: 'bucket',
      domain: 'domain',
    }),
  ],
})
export class AppModule {}

Async Usage

UpyunModule provide forRoot and forRootAsync methods to create upyun client.

import { Module } from '@nestjs/common';
import { UpyunModule } from '@nailyjs.nest.modules/upyun';

@Module({
  imports: [
    UpyunModule.forRootAsync({
      useFactory: () => ({
        operator: 'operator',
        password: 'password',
        bucket: 'bucket',
      }),
    }),
  ],
})
export class AppModule {}

Use UpyunService

Then you can use UpyunService in your service or controller.

import { Injectable } from '@nestjs/common';
import { UpyunService } from '@nailyjs.nest.modules/upyun';

@Injectable()
export class AppService {
  constructor(private readonly upyunService: UpyunService) {}

  async upload() {
    return this.upyunService.listDir('/');
  }
}

Multiple Upyun Instances

import { Module } from '@nestjs/common';
import { UpyunModule } from '@nailyjs.nest.modules/upyun';

// In real project, recommend to create a separate file to store constants.
export const UPYUN_CLIENT_1 = 'upyun1';
export const UPYUN_CLIENT_2 = 'upyun2';

@Module({
  imports: [
    UpyunModule.forRoot([
      {
        provide: UPYUN_CLIENT_1,
        operator: 'operator1',
        password: 'password1',
        bucket: 'bucket1',
      },
      {
        name: UPYUN_CLIENT_2,
        operator: 'operator2',
        password: 'password2',
        bucket: 'bucket2',
      },
    ])
  ],
})
export class AppModule {}

Also you can use forRootAsync to create multiple upyun instances.

Then you must use @Inject decorator (import from @nestjs/common) to inject the service.

import { Injectable, Inject } from '@nestjs/common';
import { UpyunService } from '@nailyjs.nest.modules/upyun';
import { UPYUN_CLIENT_1, UPYUN_CLIENT_2 } from './app.module';

@Injectable()
export class AppService {
  constructor(
    @Inject(UPYUN_CLIENT_1)
    private readonly upyunService1: UpyunService,
    @Inject(UPYUN_CLIENT_2)
    private readonly upyunService2: UpyunService,
  ) {}

  async upload() {
    return this.upyunService1.listDir('/');
  }
}

FAQ

Why I not have types for upyun sdk?

Upyun sdk is written in javascript, but you can use @types/upyun to get types.

pnpm i -D @types/upyun

The author of @types/upyun is also me (QAQ)

Author

👤 Naily Zero [email protected]

License

MIT