BugFixes bzgl. Observables, Logging Anpassungen, Endpunkt hardening, dotenv-flow usage

This commit is contained in:
2024-09-20 13:49:50 +02:00
parent 205793faab
commit 3e84b82c92
25 changed files with 141 additions and 181 deletions

View File

@@ -12,7 +12,7 @@ export class BrokerListingsController {
) {}
@Post('search')
find(@Body() criteria: UserListingCriteria): any {
return this.userService.searchUserListings(criteria);
async find(@Body() criteria: UserListingCriteria): Promise<any> {
return await this.userService.searchUserListings(criteria);
}
}

View File

@@ -280,14 +280,4 @@ export class BusinessListingService {
})
.where(sql`${businesses.id} = ${id}`);
}
// ##############################################################
// States
// ##############################################################
// async getStates(): Promise<any[]> {
// return await this.conn
// .select({ state: businesses.state, count: sql<number>`count(${businesses.id})`.mapWith(Number) })
// .from(businesses)
// .groupBy(sql`${businesses.state}`)
// .orderBy(sql`count desc`);
// }
}

View File

@@ -16,48 +16,46 @@ export class BusinessListingsController {
@UseGuards(OptionalJwtAuthGuard)
@Get(':id')
findById(@Request() req, @Param('id') id: string): any {
return this.listingsService.findBusinessesById(id, req.user as JwtUser);
async findById(@Request() req, @Param('id') id: string): Promise<any> {
return await this.listingsService.findBusinessesById(id, req.user as JwtUser);
}
@UseGuards(JwtAuthGuard)
@Get('favorites/all')
findFavorites(@Request() req): any {
return this.listingsService.findFavoriteListings(req.user as JwtUser);
async findFavorites(@Request() req): Promise<any> {
return await this.listingsService.findFavoriteListings(req.user as JwtUser);
}
@UseGuards(OptionalJwtAuthGuard)
@Get('user/:userid')
findByUserId(@Request() req, @Param('userid') userid: string): Promise<BusinessListing[]> {
return this.listingsService.findBusinessesByEmail(userid, req.user as JwtUser);
async findByUserId(@Request() req, @Param('userid') userid: string): Promise<BusinessListing[]> {
return await this.listingsService.findBusinessesByEmail(userid, req.user as JwtUser);
}
@UseGuards(OptionalJwtAuthGuard)
@Post('find')
find(@Request() req, @Body() criteria: BusinessListingCriteria): any {
return this.listingsService.searchBusinessListings(criteria, req.user as JwtUser);
async find(@Request() req, @Body() criteria: BusinessListingCriteria): Promise<any> {
return await this.listingsService.searchBusinessListings(criteria, req.user as JwtUser);
}
@UseGuards(OptionalJwtAuthGuard)
@Post('findTotal')
findTotal(@Request() req, @Body() criteria: BusinessListingCriteria): Promise<number> {
return this.listingsService.getBusinessListingsCount(criteria, req.user as JwtUser);
async findTotal(@Request() req, @Body() criteria: BusinessListingCriteria): Promise<number> {
return await this.listingsService.getBusinessListingsCount(criteria, req.user as JwtUser);
}
@Post()
create(@Body() listing: any) {
this.logger.info(`Save Listing`);
return this.listingsService.createListing(listing);
async create(@Body() listing: any) {
return await this.listingsService.createListing(listing);
}
@Put()
update(@Body() listing: any) {
this.logger.info(`Save Listing`);
return this.listingsService.updateBusinessListing(listing.id, listing);
async update(@Body() listing: any) {
return await this.listingsService.updateBusinessListing(listing.id, listing);
}
@Delete('listing/:id')
deleteById(@Param('id') id: string) {
this.listingsService.deleteListing(id);
async deleteById(@Param('id') id: string) {
await this.listingsService.deleteListing(id);
}
@UseGuards(JwtAuthGuard)
@Delete('favorite/:id')
deleteFavorite(@Request() req, @Param('id') id: string) {
this.listingsService.deleteFavorite(id, req.user as JwtUser);
async deleteFavorite(@Request() req, @Param('id') id: string) {
await this.listingsService.deleteFavorite(id, req.user as JwtUser);
}
}

View File

@@ -18,18 +18,18 @@ export class CommercialPropertyListingsController {
@UseGuards(OptionalJwtAuthGuard)
@Get(':id')
findById(@Request() req, @Param('id') id: string): any {
return this.listingsService.findCommercialPropertiesById(id, req.user as JwtUser);
async findById(@Request() req, @Param('id') id: string): Promise<any> {
return await this.listingsService.findCommercialPropertiesById(id, req.user as JwtUser);
}
@UseGuards(JwtAuthGuard)
@Get('favorites/all')
findFavorites(@Request() req): any {
return this.listingsService.findFavoriteListings(req.user as JwtUser);
async findFavorites(@Request() req): Promise<any> {
return await this.listingsService.findFavoriteListings(req.user as JwtUser);
}
@UseGuards(OptionalJwtAuthGuard)
@Get('user/:email')
findByEmail(@Request() req, @Param('email') email: string): Promise<CommercialPropertyListing[]> {
return this.listingsService.findCommercialPropertiesByEmail(email, req.user as JwtUser);
async findByEmail(@Request() req, @Param('email') email: string): Promise<CommercialPropertyListing[]> {
return await this.listingsService.findCommercialPropertiesByEmail(email, req.user as JwtUser);
}
@UseGuards(OptionalJwtAuthGuard)
@Post('find')
@@ -38,27 +38,25 @@ export class CommercialPropertyListingsController {
}
@UseGuards(OptionalJwtAuthGuard)
@Post('findTotal')
findTotal(@Request() req, @Body() criteria: CommercialPropertyListingCriteria): Promise<number> {
return this.listingsService.getCommercialPropertiesCount(criteria, req.user as JwtUser);
async findTotal(@Request() req, @Body() criteria: CommercialPropertyListingCriteria): Promise<number> {
return await this.listingsService.getCommercialPropertiesCount(criteria, req.user as JwtUser);
}
@Post()
async create(@Body() listing: any) {
this.logger.info(`Save Listing`);
return await this.listingsService.createListing(listing);
}
@Put()
async update(@Body() listing: any) {
this.logger.info(`Save Listing`);
return await this.listingsService.updateCommercialPropertyListing(listing.id, listing);
}
@Delete('listing/:id/:imagePath')
deleteById(@Param('id') id: string, @Param('imagePath') imagePath: string) {
this.listingsService.deleteListing(id);
async deleteById(@Param('id') id: string, @Param('imagePath') imagePath: string) {
await this.listingsService.deleteListing(id);
this.fileService.deleteDirectoryIfExists(imagePath);
}
@UseGuards(JwtAuthGuard)
@Delete('favorite/:id')
deleteFavorite(@Request() req, @Param('id') id: string) {
this.listingsService.deleteFavorite(id, req.user as JwtUser);
async deleteFavorite(@Request() req, @Param('id') id: string) {
await this.listingsService.deleteFavorite(id, req.user as JwtUser);
}
}