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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@lactea-blue/universe

v1.4.6-beta-6

Published

common class or functions library

Readme

Description

공통적으로 쓰이는 함수 및 module, decorator 등을 모아놓은 라이브러리.

라이브러리를 만들어, 코드 중복을 막고 수정을 간편하게 하기 위해 만들어졌다.
라이브러리에 대한 자세한 설명은 아래의 링크에 있다. 해당 라이브러리를 사용할 때, 참고하여 사용하면 편리하다.
https://lactea-blue-library.s3.ap-northeast-2.amazonaws.com/universe/index.html

Installation

$ npm i @lactea-blue/universe 

jwt module 사용법

  1. jwt service를 사용하고자 하는 곳의 Host module에 아래와 같이 JwtConfigModule을 Import 해준다.
  2. 그 후, 필요한 곳에 JwtService를 inject하여 사용하면 된다.
@Module({
  imports: [
    JwtConfigModule
  ],
  controllers: [ SampleController ],
  providers: [
    SamepleService
  ],
})
export class SampleModule {}
@Injectable()
export class SampleService {
  constructor(
    private readonly JwtUtilService: JwtUtilService,
    private readonly jwtService: JwtService
  ) {
  }
}

ApiCall

  • ApiCall은 외부 API를 편리하기 호출하기 위해 만들어진 데코레이터다.

ApiCall 사용법

  1. 호출하고자 하는 HOST를 ./env/.env.{운영환경} 파일 또는 ./common/env/{운영환경}/.env.host 파일에 작성한다.
    • 우선순위 : ./env/.env
EXAMPLE_HOST="https://example.com"
  1. 클래스 레벨에서 @ApiCall 데코레이터를 설정한다.
    • hostName : 호출하고 하는 API의 HOST (필수 값)
      • .env 파일에 작성한 변수명
    • headers: 공통적으로 사용하는 헤더 값들 (선택 값)
@Injectable()
@ApiCall(
    "EXAMPLE_HOST",
    {
       "Content-Type" : "application/json",
    }
)
export class ExampleApiClient { }

@Injectable()
@ApiCall(
  "EXAMPLE_HOST",
)
export class ExampleApiClient { }
  1. 외부 호출이 필요한 메소드를 ApiCall 전용 Http Method 데코레이터와 Paramter 데코레이터와 함께 작성한다. cf) NestJs에서 제공하는 데코레이터와 거의 유사하다. (Import시 주의)

    • ApiCall 전용 Http Method 데코레이터
      • @Get()
      • @Post()
      • @Put()
      • @Delete()
    • ApiCall 전용 Parameter 데코레이터
      • @Body()
      • @Query()
      • @Param()
      • @Header()
@Get("/search")
async searchUser(@Query("name") userName: string): Promise<GetUserInfoRes> { return }

@Post("/user")
async createUser(@Body() req: createUserReq): Promise<CreateUserRes> { return }

@Put("/users/{:id}")
async updateUser(
    @Param("id") userId: string, 
    @Body() req: UpdateUserReq,
): Promise<UpdateUserRes> { return }

@Delete("/users")
async deleteUser(@Query("userId") userId: string): Promise<DelteUserRes> { return }

특정 메소드에만 header 정보를 추가하고 싶을 때

@Put("/users/{:id}")
async updateUser(
    @Header("Content-Type") contentType: string,
    @Param("id") userId: string,
    @Body() req: UpdateUserReq,
): Promise<UpdateUserRes> { return }

만약 공통 헤더와 메소드 헤더의 key값이 같다면 메소드의 헤더의 value가 우선 순위가 된다.


@Injectable()
@ApiCall(
  "EXAMPLE_HOST",
  {
    "Content-Type" : "application/json",
  }
)
export class ExampleApiClient {

  @Put("/users/{:id}")
  async updateUser(
    @Header("Content-Type") contentType: string,
  ): Promise<UpdateUserRes> { return }
}

ApiCall 사용 예제

@Injectable()
@ApiCall(
  "EXAMPLE_HOST",
  {
    "Content-Type" : "application/json",
  }
)
export class ExampleApiClient {

    @Post("/example")
    async callExample(@Body() req: ExampleReq): Promise<ExampleRes> { return }
}
@Injectable()
export class ExampleService {
  
    constructor(
        private readonly exampleApiClient: ExampleApiClient,
    )
    
    async doExample(req: ExampleReq): Promise<ExampleRes> {
        let response: ExampleRes = exampleApiClient.callExample(req)
        // 비즈니스 로직 작성
    }
}