Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hebertcisco/nestjs-techniques-undici
Undici module example: https://github.com/hebertcisco/nestjs-undici
https://github.com/hebertcisco/nestjs-techniques-undici
nestjs nestjs-boilerplate nestjs-undici typescript undici
Last synced: 1 day ago
JSON representation
Undici module example: https://github.com/hebertcisco/nestjs-undici
- Host: GitHub
- URL: https://github.com/hebertcisco/nestjs-techniques-undici
- Owner: hebertcisco
- Created: 2022-06-26T22:34:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-05T02:22:35.000Z (about 1 month ago)
- Last Synced: 2024-12-05T02:27:41.180Z (about 1 month ago)
- Topics: nestjs, nestjs-boilerplate, nestjs-undici, typescript, undici
- Language: TypeScript
- Homepage:
- Size: 1.98 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/hebertcisco/nestjs-techniques-undici)
[![🚀 Build](https://github.com/hebertcisco/nestjs-techniques-undici/actions/workflows/build.yml/badge.svg)](https://github.com/hebertcisco/nestjs-techniques-undici/actions/workflows/build.yml)
# Basic documentation
### Usage example:
```ts
// app.module.ts
import { Module } from '@nestjs/common';
import { HttpModule } from 'nestjs-undici';import { AppController } from './app.controller';
import { AppService } from './app.service';@Module({
imports: [
HttpModule.register({
headers: {
'my-header': `foo-bar`,
},
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
``````ts
// app.service.ts
import { lastValueFrom } from 'rxjs';import { Injectable } from '@nestjs/common';
import { HttpService } from 'nestjs-undici';@Injectable()
export class AppService {
constructor(private httpService: HttpService) {}
public fetchExternalInfo = async () => {
const baseURL = 'https://api.github.com';
try {
const result = this.httpService.request(
`${baseURL}/repos/hebertcisco/undici`,
);const response = await lastValueFrom(result);
return response.body.json();
} catch (error) {
throw error;
}
};
}
```## Runing the application with docker
### Run as dev
```sh
docker-compose up dev
```### Run as prod
```sh
docker-compose up -d prod
```## Runing the application with npm scrips
```sh
npm install && npm run build
``````sh
npm run prepare:enviroment
```### Run as dev
```sh
npm run dev
```or
```sh
npm run dev:test
```### Run as prod
```sh
npm run start
```or
```sh
npm run start:prod
```