Initial web app consumption/integration (#5)
Co-authored-by: Joe Arndt <jmarndt@users.noreply.github.com> Reviewed-on: #5
This commit is contained in:
parent
3f258bcd33
commit
df6733caa9
41 changed files with 385 additions and 353 deletions
|
|
@ -15,7 +15,7 @@ import {
|
|||
import { ExpensesService } from './expenses.service';
|
||||
import { CreateExpenseDto } from './dto/create-expense.dto';
|
||||
import { UpdateExpenseDto } from './dto/update-expense.dto';
|
||||
import { Expense } from './entities/expense.entity';
|
||||
import { GetExpenseDto } from './dto/get-expense.dto';
|
||||
|
||||
@Controller('expenses')
|
||||
export class ExpensesController {
|
||||
|
|
@ -23,13 +23,13 @@ export class ExpensesController {
|
|||
|
||||
@Get()
|
||||
@HttpCode(HttpStatus.OK)
|
||||
public async findAll(): Promise<Expense[]> {
|
||||
public async findAll(): Promise<GetExpenseDto[]> {
|
||||
return await this.expensesService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
public async findOne(@Param('id') id: string): Promise<Expense> {
|
||||
public async findOne(@Param('id') id: string): Promise<GetExpenseDto> {
|
||||
if (!id) {
|
||||
throw new BadRequestException('No ID provided.');
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ export class ExpensesController {
|
|||
|
||||
@Post()
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
public async create(@Body() expense: CreateExpenseDto): Promise<Expense> {
|
||||
public async create(@Body() expense: CreateExpenseDto): Promise<GetExpenseDto> {
|
||||
if (!expense) {
|
||||
throw new BadRequestException('Expense name cannot be empty.');
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ export class ExpensesController {
|
|||
|
||||
@Put()
|
||||
@HttpCode(HttpStatus.OK)
|
||||
public async update(@Body() expense: UpdateExpenseDto): Promise<Expense> {
|
||||
public async update(@Body() expense: UpdateExpenseDto): Promise<GetExpenseDto> {
|
||||
if (!expense.id) {
|
||||
throw new BadRequestException('Expense ID cannot be empty.');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue