Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iamnnort/nestjs-request
Request module for NestJS - Simple - Fast - Informative
https://github.com/iamnnort/nestjs-request
Last synced: 10 days ago
JSON representation
Request module for NestJS - Simple - Fast - Informative
- Host: GitHub
- URL: https://github.com/iamnnort/nestjs-request
- Owner: iamnnort
- License: mit
- Created: 2024-02-15T21:12:46.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-02-23T18:49:08.000Z (9 months ago)
- Last Synced: 2024-04-25T05:22:26.018Z (7 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@iamnnort/nestjs-request
- Size: 297 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Security: SECURITY.md
Awesome Lists containing this project
README
## Info
Request module for NestJS - Simple - Informative - Pretty
## Installation
```bash
yarn install @iamnnort/nestjs-request
```## Usage
```javascript
// app.controller.ts
import { Controller, Get } from '@nestjs/common';
import { RequestService } from '@iamnnort/nestjs-request';@Controller('demo')
export class AppController {
constructor(private requestService: RequestService<{ id: number }>) {}@Get()
demo() {
return this.requestService.get(1);
}
}// app.ts
import { Module } from '@nestjs/common';
import { RequestModule } from '@iamnnort/nestjs-request';
import { AppController } from './app.controller';@Module({
imports: [
RequestModule.register({
name: 'Demo Api',
baseUrl: 'https://jsonplaceholder.typicode.com',
url: '/todos',
logger: true,
}),
],
controllers: [AppController],
})
export class AppModule {}// index.ts
import { NestFactory } from '@nestjs/core';
import { LoggerService } from '@iamnnort/nestjs-logger';
import { AppModule } from './app';async function bootstrap() {
const app = await NestFactory.create(AppModule, {
bufferLogs: true,
});app.useLogger(new LoggerService());
await app.listen(3000);
}bootstrap();
```## Output
```bash
[System] Application is starting...
[System] Application started.
[System] [Request] GET /demo
[Demo Api] [Request] GET /todos/1
[Demo Api] [Response] GET /todos/1 200 OK {"userId":1,"id":1,"title":"delectus aut autem","completed":false}
[System] [Response] GET /demo 200 OK
```## License
This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.