added expenses resource

This commit is contained in:
Joe Arndt 2026-02-09 13:53:42 -06:00
parent c6434de89d
commit 78c312f279
27 changed files with 310 additions and 86 deletions

View file

@ -0,0 +1,35 @@
import { Injectable } from '@nestjs/common';
import { CreateExpenseDto } from './dto/create-expense.dto';
import { UpdateExpenseDto } from './dto/update-expense.dto';
import { ExpenseDataService } from './expense-data.service';
import { Expense } from './entities/expense.entity';
@Injectable()
export class ExpensesService {
public constructor(private expenseDataService: ExpenseDataService) { }
public async findAll(): Promise<Expense[]> {
return await this.expenseDataService.getAll();
}
public async findById(id: string): Promise<Expense> {
const expense = await this.expenseDataService.getById(id);
if (!expense) {
throw new Error('No expense found');
}
return expense;
}
public async create(expense: CreateExpenseDto): Promise<Expense> {
return await this.expenseDataService.create(expense);
}
public async update(expense: UpdateExpenseDto): Promise<Expense> {
return await this.expenseDataService.update(expense);
}
public async remove(id: string): Promise<void> {
await this.expenseDataService.delete(id);
}
}