1.0.21 • Published 8 months ago
@los_generic/shared v1.0.21
@los_generic/shared
A public shared library containing DTOs, interfaces, utilities, and other common code for LOS applications.
Installation
npm install @los_generic/sharedFeatures
DTOs: Reusable Data Transfer Objects with validation
- Country DTOs (CreateCountryDto, UpdateCountryDto)
- More DTOs can be added as needed
Interfaces: Common TypeScript interfaces
- Pagination interfaces
- Base interfaces
Utils: Utility functions
- Pagination utilities
- More utilities can be added as needed
Usage Examples
Using DTOs
import { CreateCountryDto, UpdateCountryDto } from '@los_generic/shared';
@Post()
async createCountry(@Body() createCountryDto: CreateCountryDto) {
// DTO will automatically validate the input
return this.countryService.create(createCountryDto);
}
@Put(':id')
async updateCountry(
@Param('id') id: string,
@Body() updateCountryDto: UpdateCountryDto
) {
return this.countryService.update(id, updateCountryDto);
}Using Pagination
import {
PaginationParams,
createPaginatedResponse,
getPaginationParams
} from '@los_generic/shared';
@Get()
async findAll(@Query() query: PaginationParams) {
const params = getPaginationParams(query);
const [items, total] = await this.repository.findAndCount({
skip: (params.page - 1) * params.limit,
take: params.limit,
order: { [params.sortBy]: params.sortOrder }
});
return createPaginatedResponse(items, total, params);
}Development
- Install dependencies:
npm install- Build the package:
npm run build- Watch for changes during development:
npm run watchPublishing
This package is published as a public package under the @los_generic organization.
# For bug fixes (0.0.x)
npm run patch
# For new features (0.x.0)
npm run minor
# For breaking changes (x.0.0)
npm run majorDependencies
Peer Dependencies
- @nestjs/common: ^10.0.0
- class-transformer: ^0.5.1
- class-validator: ^0.14.0
Make sure these peer dependencies are installed in your project.
Project Structure
src/
├── modules/
│ └── country/
│ ├── dto/
│ │ ├── create-country.dto.ts
│ │ └── update-country.dto.ts
│ ├── index.ts
│ └── pattern.ts
└── index.tsLicense
ISC
1.0.23
8 months ago
1.0.22
8 months ago
1.0.21
8 months ago
1.0.20
8 months ago
1.0.19
8 months ago
1.0.18
8 months ago
1.0.17
8 months ago
1.0.16
8 months ago
1.0.15
8 months ago
1.0.14
8 months ago
1.0.13
8 months ago
1.0.12
8 months ago
1.0.10
8 months ago
1.0.9
8 months ago
1.0.8
8 months ago
1.0.7
8 months ago
1.0.6
8 months ago
1.0.5
8 months ago
1.0.4
8 months ago
1.0.3
8 months ago
1.0.2
8 months ago
1.0.1
8 months ago
1.0.0
8 months ago