1.0.23 • Published 10 months ago
@los_generic/shared v1.0.23
@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
10 months ago
1.0.22
10 months ago
1.0.21
10 months ago
1.0.20
10 months ago
1.0.19
10 months ago
1.0.18
10 months ago
1.0.17
11 months ago
1.0.16
11 months ago
1.0.15
11 months ago
1.0.14
11 months ago
1.0.13
11 months ago
1.0.12
11 months ago
1.0.10
11 months ago
1.0.9
11 months ago
1.0.8
11 months ago
1.0.7
11 months ago
1.0.6
11 months ago
1.0.5
11 months ago
1.0.4
11 months ago
1.0.3
11 months ago
1.0.2
11 months ago
1.0.1
11 months ago
1.0.0
11 months ago