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 🙏

© 2026 – Pkg Stats / Ryan Hefner

res-saas-gl-library

v1.0.131

Published

A NestJS library for gRPC communication between microservices

Readme

Description

Library for centralizing and abstracting work with .proto files and gRPC requests.

Prerequisites

Before starting, make sure you have the following installed in your local environment:


In this version only the following microservices are available:

  • Auth
  • Documentation
  • Notification
  • Storage

Installation

$ pnpm install

If you dont want install from npm, you can install locally

$ pnpm install /route/to/local/folder/res-saas-gl-library

generate interfaces from proto files

$ pnpm run generate:proto

create build

$ pnpm run build

upgrading version

$ pnpm version patch

publish package

$ pnpm publish

Usage

Install Library

$ pnpm install saas-grpc-library

Example for using the library

Usage the Infisical Module:

  • Create a global module as shown below:
//infisical.common.module.ts
import { Global, Module } from '@nestjs/common';
import { InfisicalService } from '../infisical.service';
@Global()
@Module({
    providers: [InfisicalService],
    exports: [InfisicalService],
})
export class InfisicalModule {}
  • In this module file create the Infisical Service:
//infisical.service.ts
import { Injectable, Logger } from '@nestjs/common';
import {
    InfisicalClientService,
    InfisicalClientInterface,
} from 'res-saas-gl-library';
import { env } from '../env/env';

@Injectable()
export class InfisicalService implements InfisicalClientInterface {
    private infisicalClient: InfisicalClientService;
    private logger = new Logger(InfisicalService.name);
    constructor() {
        this.initializeInfisicalClient();
    }

    private initializeInfisicalClient() {
        const infisicalEnv = env.INFISICAL_ENV;
        const infisicalProjectId = env.INFISICAL_PROJECT_ID;
        const infisicalToken = env.INFISICAL_TOKEN;
        const infisicalUrl = env.INFISICAL_URL;
        const infisicalSecretPath = env.INFISICAL_SECRET_PATH;

        this.infisicalClient = InfisicalClientService.getInstance(
            infisicalEnv,
            infisicalProjectId,
            infisicalToken,
            infisicalUrl,
            infisicalSecretPath,
        );
    }

    public async getSecrets(): Promise<Record<string, string>> {
        return this.infisicalClient.getSecrets();
    }

    public async getSecret(key: string): Promise<string> {
        const secrets = await this.infisicalClient.getSecrets();
        const value = secrets[key];
        if (!value) {
            this.logger.warn(`Secret ${key} not found in Infisical.`);
        }
        return value;
    }
}
  • Import the global module in the app module as shown below:
//app.module.ts
import { Module } from '@nestjs/common';
import { InfisicalModule, InfisicalService } from './common/infisical/infisical.common.module';

@Module({
  imports: [InfisicalModule],
  controllers: [],
  providers: [InfisicalService],
})
export class AppModule {}

Usage the Grpc Modules

  • In the module that you want to use the library, import the library as shown below:
//auth-grpc.module.ts
import { AuthServiceClient, GRPCAuthModule } from 'saas-grpc-library';

@Module({
    imports: [
        GRPCAuthModule.register(process.env.GRPC_AUTH_DOMAIN),
    ],
    providers: [ AuthServiceClient],
    exports: [ AuthServiceClient],
})
export class AuthGrpcModule {}
  • Import the client in the service
//auth-grpc.service.ts
import {
    AuthServiceClient,
    GetPermissionsRequest,
    GetUserProfileRequest,
    SetServicesRequest,
} from 'saas-grpc-library';

@Injectable()
export class AuthGrpcService {
    constructor(private readonly authServiceClient: AuthServiceClient) {}

    getPermissions(data: GetPermissionsRequest) {
        return this.authServiceClient.getPermissions(data);
    }
    setServices(request: SetServicesRequest) {
        return this.authServiceClient.setServices(request);
    }

    getUserProfile(request: GetUserProfileRequest) {
        return this.authServiceClient.getUserProfile(request);
    }
}

Usage in the guard

  • Create a global module as shown below:
//auth.common.module.ts
import { Global, Module } from '@nestjs/common';
import { InfisicalService } from '../../config/infisical/infisical.service';
import { JwtModule, JwtService } from '@nestjs/jwt';
import {
  PublicKeyService,
  GRPCAuthModule,
  AuthServiceClient,
} from 'res-saas-gl-library';

@Global()
@Module({
  imports: [
    JwtModule.register({}),
    GRPCAuthModule.registerAsync({
      inject: [InfisicalService],
      useFactory: async (infisicalService: InfisicalService) => {
        const url = await infisicalService.getSecret('GRPC_AUTH_DOMAIN');
        return { url: url };
      },
    }),
  ],
  controllers: [],
  providers: [
    { provide: 'InfisicalService', useClass: InfisicalService },
    {
      provide: 'JwtService',
      useClass: JwtService,
    },
    PublicKeyService,
    AuthServiceClient,
  ],
  exports: [
    'InfisicalService',
    'JwtService',
    PublicKeyService,
    AuthServiceClient,
  ],
})
export class AuthCommonModule {}
  • Import the global module in the app module as shown below:
//app.module.ts
import { Module } from '@nestjs/common';
import { AuthCommonModule } from './common/auth/auth.common.module';

@Module({
  imports: [AuthCommonModule],
  controllers: [],
  providers: [],
})
export class AppModule {}

Usage of the filters, loggingMiddleware, interceptors, formatResponses and formatErrors

  • Import CommonModule in AppModule
//app.module.ts
import { Module } from '@nestjs/common';
import { CommonModule } from 'res-saas-gl-library';

@Module({
  imports: [CommonModule],
  controllers: [],
  providers: [],
})
export class AppModule {}

Stay in touch

License

Nest is MIT licensed.