# easy-tracer

> A library to trace requests and responses functions in Nestjs. The main advantage to this library is to debug between request and response logs inside some environment or local machine. It is useful to trace data flows in microservices or monolithic.

Latest version **1.2.5** (published 2023-05-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install easy-tracer
pnpm add easy-tracer
yarn add easy-tracer
bun add easy-tracer
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.5 |
| Published | 2023-05-25 |
| First published | 2023-05-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 31.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Diego Kraenau |
| Maintainers | diegokraenau |

## Links

- npm: https://www.npmjs.com/package/easy-tracer
- npm.io page: https://npm.io/package/easy-tracer

## Dependencies (4)

- [rxjs](https://npm.io/package/rxjs.md) ^7.8.1
- [moment](https://npm.io/package/moment.md) ^2.29.4
- [rimraf](https://npm.io/package/rimraf.md) ^5.0.1
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) ^9.4.2

## Recent versions

- 1.2.5 (latest) — 2023-05-25

## README

# Easy Tracer

A library to trace requests and responses functions in Nestjs. The main advantage to this library is to debug between request and response logs inside some environment or local machine. It is useful to trace data flows in microservices or monolithic.



## Install

Run the following command

```bash
  npm i easy-tracer
```

## Setup Module
First of all, you will need setup the module.

```
import { EasyTracerModule } from 'easy-tracer';

@Module({
  imports: [
    ...
    EasyTracerModule.forRoot({
      showLogs: true,
    }),
  ],
  controllers: [...],
  providers: [...],
})
export class AppModule {};
```

| - | Description |
| --- | --- |
| showLogs | Boolean to enable or disable logs in root. |


## Trace a Controller
Trace decorator mainly works in controller to trace the request and response function.

```
import { Trace } from 'easy-tracer';

@Controller('...')
export class TestController {
  constructor(...) {}

  @Get('...')
  @Trace()
  async test(...) {
    return ...;
  }

```

## Methods
The followins methos are:

```
    * @Trace(): Enable trace.
    * @Trace({ showLogs: false }): Disable trace.
```

## Output
When trace is enable, you will find two logs in your console about the request and response function.
| Formats | Example |
| --- | --- |
| Request | Request - functionName - MM/DD/YYYY HH:mm:ss -> [Params] |
| Response | Response - functionName - MM/DD/YYYY HH:mm:ss -> [Response] |

Here the example:

```
//Example function
@Post()
@Trace()
async addEvent(@Body() dto: RegisterEvent) {
  await this.eventService.addEvent(dto);
  return { message: 'Event was added' };
}

//Tracing the function in console
[Nest] 24360  - 24/05/2023, 11:29:55 p. m. VERBOSE Request - addEvent - 05/24/2023 23:29:55 -> [{"priority":"HIGH","sent":false}]
[Nest] 24360  - 24/05/2023, 11:29:55 p. m. VERBOSE Response - addEvent - 05/24/2023 23:29:55 -> {"message":"Event was added"}

```

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