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,26 @@
import { Inject } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { Branch } from '../models/Branch.model';
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
@Injectable()
export class GetBranchService {
constructor(
@Inject(Branch.name)
private readonly branch: TenantModelProxy<typeof Branch>,
) {}
/**
* Retrieves the given branch details.
* @param {number} branchId
* @returns {Promise<IBranch>}
*/
public getBranch = async (branchId: number): Promise<Branch> => {
const branch = await this.branch()
.query()
.findById(branchId)
.throwIfNotFound();
return branch;
};
}

View File

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