0.11.1 • Published 1 year ago

nestjs-base-service v0.11.1

Weekly downloads
118
License
MIT
Repository
github
Last release
1 year ago

NestJS BaseService

An opinionated base service for NestJS

Test Coverage

Built with :heartpulse: at Vizzuality.

Roadmap

  • Add tutorial
  • Add tests
  • Implement transaction support
  • Implement opinionated batching
  • Add support for validation (via plugin?)
  • Add support for auditing (via plugin?)
  • Add support for pagination
  • Add support for serialization
  • Add support for batching of operations

License

(C) Copyright Vizzuality 2020-2021.

Distributed under the MIT license.

Usage

Filtering on listing GET requests

  • Add the necessary decorator to your request parsing, on your controller method, like so:
import {
  FetchSpecification,
  ProcessFetchSpecification,
} from 'nestjs-base-service';

@Controller(`/api/v1/some-model`)
@ApiTags(someModelResource.className)
export class SomeModelController {
  constructor(public readonly someModelsService: SomeModelsService) {}

  @Get()
  async findAll(
    @ProcessFetchSpecification(['status'])
      fetchSpecification: FetchSpecification,
  ): Promise<SomeModel> {
    const results = await this.someModelsService.findAllPaginated(
      fetchSpecification,
    );
    return this.someModelsService.serialize(results.data, results.metadata);
  }
}
  • Ensure your service class extends the included BaseService class.
  • On your controller decorator argument, optionally pass a whitelist of filtering parameters (recommended).
0.11.0

1 year ago

0.11.1

1 year ago

0.10.0

1 year ago

0.9.0

2 years ago

0.8.1

2 years ago

0.8.2

2 years ago

0.8.0

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.4.6

3 years ago

0.5.0

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago