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

parse-google-env-credentials

v1.0.9

Published

Verify if the google credentials are correctly defined on your env and return the values of them to use in ExpressJs or NestJS

Downloads

9

Readme

  1. The Problem
  2. The Solution
  3. Getting Started
    1. Installation
    2. Variables
  4. Usage
    1. Express
    2. NestJs
  5. Resume

The Problem 📋

In the cases that we want to use the google functionality, we need to use a configuration file in JSON format but this is an unsecured method to expose our google credentials into our project

The Solution 💡

So, instead of using this file, this configuration could be saved into an environment variable, and nodejs-utils is the charge to search this variable and validate if first the variable was set correctly, second: validate if the content of the variable was a valid and third convert to a valid JSON type from a string. Also, this library was created with another purpose, to use for setting the logging for the current app using Pino with Pino-http so if you using an ExpressJs or a NestJs project this configure the logger for the corresponding type of project.

Getting Started 🏁

Installation ⚙️

This module is distributed via npm which is bundled with node and should be installed as one of your project's Dependencies:

npm install --save nodejs-utils

or

for installation via yarn

yarn add nodejs-utils

Variables 📫

You need to set into your project these environment variables:

Required

  • NODE_ENV

Required only in production stage

  • GOOGLE_APPLICATION_CREDENTIALS
  • LOGGER_NAME

Note: The NODE_ENV variable is in the case that you are on the development you need to put development and on production should be production this is because in development stage we don't need to logger on Google cloud and in the case that you are on development the other variables GOOGLE_APPLICATION_CREDENTIALS and LOGGER_NAME it will be only required on production stage.

Usage 🛠

You must need to install pino pino-pretty and pino-stackdriver

yarn add pino pino-pretty pino-stackdriver

or

npm install --save pino pino-pretty pino-stackdriver

Express

Into your logger file or wherever that you configure into your project, you must only import ExpressLogger and declare to use the logger:

import { ExpressLogger } from 'nodejs-utils'

const logger = ExpressLogger()

logger.info('...')

NestJs

In the case that you project is on NestJs you need to install the above library:

yarn add pino nestjs-pino

or

npm install --save pino nestjs-pino

Into your app.module.ts file you should set this configuration:

import { LoggerModule } from 'nestjs-pino'
import { NestJsLogger } from 'nodejs-utils'

@Module({
  imports: [
    LoggerModule.forRoot(NestJsLogger()),
    ...
  ],
  controllers: [],
  providers: [],
})

Also into main.ts:

import { Logger } from 'nestjs-pino'

async function bootstrap() {
  ...
  app.useLogger(app.get(Logger))
  ...
}

Resume 🧾

That's all now you can start to use this library. Happy Coding 👩‍💻👨‍💻🧑‍💻