Skip to content

Commit 5f699c7

Browse files
committed
Added VSCode Launch file
1 parent 2960e3b commit 5f699c7

10 files changed

+71
-72
lines changed

.vscode/launch.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug Backend",
6+
"type": "pwa-node",
7+
"request": "launch",
8+
"args": [
9+
"apps/car-rental-backend/src/main.ts"
10+
],
11+
"runtimeArgs": [
12+
"--require",
13+
"ts-node/register",
14+
"--require",
15+
"tsconfig-paths/register",
16+
],
17+
"cwd": "${workspaceRoot}",
18+
"internalConsoleOptions": "openOnSessionStart",
19+
"env": {
20+
"NODE_ENV": "local",
21+
"NODE_PORT": "8000",
22+
"TS_NODE_PROJECT": "apps/car-rental-backend/tsconfig.app.json", // Specify the tsconfig to use
23+
},
24+
"sourceMaps": true,
25+
"console": "internalConsole",
26+
"outputCapture": "std",
27+
"resolveSourceMapLocations": [
28+
"${workspaceFolder}/**",
29+
"!**/node_modules/**" // Disable the "could not read source map" error for node_modules
30+
]
31+
}
32+
]
33+
}

apps/car-rental-backend/src/app/app.controller.spec.ts

-21
This file was deleted.

apps/car-rental-backend/src/app/app.controller.ts

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Module } from '@nestjs/common';
2-
import { AppController } from './app.controller';
3-
import { AppService } from './app.service';
42
import { TypeOrmModule } from '@nestjs/typeorm';
53
import { VehiclesModule } from '../vehicles/vehicles.module';
64
import { Vehicle } from '../vehicles/entities/vehicle.entity';
5+
import { VehicleBrand } from '../vehicle-brands/entities/vehicle-brand.entity';
76

87
@Module({
98
imports: [
@@ -14,12 +13,12 @@ import { Vehicle } from '../vehicles/entities/vehicle.entity';
1413
username: 'root',
1514
password: 'root',
1615
database: 'car_rental',
17-
entities: [Vehicle],
16+
entities: [Vehicle, VehicleBrand],
1817
synchronize: true,
1918
}),
2019
VehiclesModule,
2120
],
22-
controllers: [AppController],
23-
providers: [AppService],
21+
controllers: [],
22+
providers: [],
2423
})
2524
export class AppModule {}

apps/car-rental-backend/src/app/app.service.spec.ts

-20
This file was deleted.

apps/car-rental-backend/src/app/app.service.ts

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
export class CreateVehicleBrandDto {}
1+
import { ApiProperty } from "@nestjs/swagger";
2+
3+
export class CreateVehicleBrandDto {
4+
@ApiProperty({ example: 'Toyota', description: 'The name of the vehicle brand', type: 'string' })
5+
name: string;
6+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { PartialType } from '@nestjs/swagger';
1+
import { PickType } from '@nestjs/swagger';
22
import { CreateVehicleBrandDto } from './create-vehicle-brand.dto';
33

4-
export class UpdateVehicleBrandDto extends PartialType(CreateVehicleBrandDto) {}
4+
export class UpdateVehicleBrandDto extends PickType(CreateVehicleBrandDto, ['name'] as const) {
5+
}

apps/car-rental-backend/src/vehicle-brands/vehicle-brands.service.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@nestjs/common';
1+
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
22
import { CreateVehicleBrandDto } from './dto/create-vehicle-brand.dto';
33
import { UpdateVehicleBrandDto } from './dto/update-vehicle-brand.dto';
44
import { InjectRepository } from '@nestjs/typeorm';
@@ -12,7 +12,15 @@ export class VehicleBrandsService {
1212
private vehicleBrandsRepository: Repository<VehicleBrand>
1313
) {}
1414

15-
create(createVehicleBrandDto: CreateVehicleBrandDto) {
15+
async create(createVehicleBrandDto: CreateVehicleBrandDto) {
16+
const { name } = createVehicleBrandDto;
17+
const vehicleBrand = await this.findByName(name);
18+
if (vehicleBrand) {
19+
throw new HttpException(
20+
{ status: HttpStatus.CONFLICT, error: 'Vehicle brand already exists' },
21+
HttpStatus.CONFLICT
22+
);
23+
}
1624
return this.vehicleBrandsRepository.save(createVehicleBrandDto);
1725
}
1826

@@ -24,6 +32,10 @@ export class VehicleBrandsService {
2432
return this.vehicleBrandsRepository.findOneBy({ id });
2533
}
2634

35+
findByName(name: string) {
36+
return this.vehicleBrandsRepository.findOneBy({ name });
37+
}
38+
2739
update(id: number, updateVehicleBrandDto: UpdateVehicleBrandDto) {
2840
return this.vehicleBrandsRepository.update(id, updateVehicleBrandDto);
2941
}

package.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
"name": "@car-rental/source",
33
"version": "0.0.0",
44
"license": "MIT",
5-
"scripts": {},
5+
"scripts": {
6+
"ng": "ng",
7+
"start": "ng serve",
8+
"build": "ng build",
9+
"test": "ng test",
10+
"lint": "ng lint",
11+
"e2e": "ng e2e",
12+
"start:api": "nest start",
13+
"start:api:dev": "nx run car-rental-backend:serve --configuration=development",
14+
"start:api:debug": "nest start --debug --watch"
15+
},
616
"private": true,
717
"dependencies": {
818
"@angular/animations": "~19.0.0",

0 commit comments

Comments
 (0)