feat(nestjs): migrate to NestJS

This commit is contained in:
Ahmed Bouhuolia
2025-04-07 11:51:24 +02:00
parent f068218a16
commit 55fcc908ef
3779 changed files with 631 additions and 195332 deletions

View File

@@ -0,0 +1,24 @@
import { Inject, Injectable } from '@nestjs/common';
import { Warehouse } from '../models/Warehouse.model';
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
@Injectable()
export class GetWarehouse {
constructor(
@Inject(Warehouse.name)
private readonly warehouseModel: TenantModelProxy<typeof Warehouse>,
) {}
/**
* Retrieves warehouse details.
* @param {number} warehouseId
* @returns {Promise<IWarehouse>}
*/
public getWarehouse = async (warehouseId: number) => {
const warehouse = await this.warehouseModel()
.query()
.findById(warehouseId)
.throwIfNotFound();
return warehouse;
};
}

View File

@@ -0,0 +1,23 @@
import { Inject, Injectable } from '@nestjs/common';
import { Warehouse } from '../models/Warehouse.model';
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
@Injectable()
export class GetWarehouses {
constructor(
@Inject(Warehouse.name)
private readonly warehouseModel: TenantModelProxy<typeof Warehouse>,
) {}
/**
* Retrieves warehouses list.
* @returns
*/
public getWarehouses = async () => {
const warehouses = await this.warehouseModel()
.query()
.orderBy('name', 'DESC');
return warehouses;
};
}