# parse-google-env-credentials

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

Latest version **1.0.9** (published 2022-01-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install parse-google-env-credentials
pnpm add parse-google-env-credentials
yarn add parse-google-env-credentials
bun add parse-google-env-credentials
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2022-01-06 |
| First published | 2021-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 195.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | https://www.ravn.co/ |
| Maintainers | ederivero |
| Keywords | RAVN, google, credentials, nestjs, express |

## Links

- npm: https://www.npmjs.com/package/parse-google-env-credentials
- Repository: https://github.com/ederivero/google-credentials-package
- Issues: https://github.com/ederivero/google-credentials-package/issues
- npm.io page: https://npm.io/package/parse-google-env-credentials

## Dependencies (2)

- [pino](https://npm.io/package/pino.md) ^7.5.1
- [pino-stackdriver](https://npm.io/package/pino-stackdriver.md) ^3.0.0

## Recent versions

- 1.0.9 (latest) — 2022-01-06
- 1.0.8 — 2021-12-31
- 1.0.7 — 2021-12-30
- 1.0.6 — 2021-12-13
- 1.0.5 — 2021-12-13
- 1.0.4 — 2021-12-03
- 1.0.3 — 2021-12-03
- 1.0.2 — 2021-12-03
- 1.0.1 — 2021-12-03
- 1.0.0 — 2021-12-03

## README

<p align="center">
    <img width="200" src="./assets/logo.png">
</p>
<br>

<h1 align="center">NodeJs Utils</h1>

1. [The Problem](#problem)
2. [The Solution](#solution)
3. [Getting Started](#getting_started)
   1. [Installation](#installation)
   2. [Variables](#variables)
4. [Usage](#usage)
   1. [Express](#express)
   2. [NestJs](#nestjs)
5. [Resume](#resume)

<hr>

### The Problem 📋<a name="problem" ></a>

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

<br>
<br>

### The Solution 💡<a name="solution" ></a>

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][expressjs] or a [NestJs][nestjs] project this configure the logger for the corresponding type of project.

<br>
<br>

## Getting Started 🏁<a name="getting_started" ></a>

### Installation ⚙️<a name="installation" ></a>

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

```
npm install --save nodejs-utils
```

or

for installation via [yarn][yarn]

```
yarn add nodejs-utils
```

### Variables 📫<a name="variables" ></a>

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.

<br>
<br>

## Usage 🛠<a name="usage" ></a>

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<a name="express" ></a>

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<a name="nestjs" ></a>

In the case that you project is on [NestJs][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))
  ...
}

```

<br>
<br>

## Resume 🧾<a name="resume" ></a>

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

[npm]: https://www.npmjs.com/
[yarn]: https://classic.yarnpkg.com
[node]: https://nodejs.org
[expressjs]: https://expressjs.com/
[nestjs]: https://nestjs.com/

---
_Source: https://npm.io/package/parse-google-env-credentials · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
