Download src/modules/property/property.controller.ts from bardd/node-pt: direct link, hf CLI and curl.
- Browser
- Download file 2.9 kB
-
https://huggingface.co/spaces/bardd/node-pt/resolve/d60fe6f60a3590cc2369b16f7e229a9e7ce53e1d/src/modules/property/property.controller.ts
- Command line
-
hf download hf://spaces/bardd/node-pt@d60fe6f60a3590cc2369b16f7e229a9e7ce53e1d/src/modules/property/property.controller.ts
-
curl -L -o property.controller.ts https://huggingface.co/spaces/bardd/node-pt/resolve/d60fe6f60a3590cc2369b16f7e229a9e7ce53e1d/src/modules/property/property.controller.ts
2.9 kB
| import { | |
| Body, | |
| Controller, | |
| Get, | |
| HttpStatus, | |
| Post, | |
| Query, | |
| Req, | |
| Res, | |
| UseGuards, | |
| } from '@nestjs/common'; | |
| import { Response } from 'express'; | |
| import { CommonServices } from '../shared/common.service'; | |
| import { PropertyService } from './property.service'; | |
| ('property') | |
| export class PropertyController extends CommonServices { | |
| constructor(private readonly propertyService: PropertyService) { | |
| super(); | |
| } | |
| ('') | |
| async getPropertListings(() res: Response, () req): Promise<any> { | |
| try { | |
| const response = await this.propertyService.sharedFind({}); | |
| return this.sendResponse( | |
| this.messages.Success, | |
| response ?? 'NOT_FOUND', | |
| HttpStatus.OK, | |
| res, | |
| ); | |
| } catch (error) { | |
| return this.sendResponse( | |
| 'Internal server Error', | |
| {}, | |
| HttpStatus.INTERNAL_SERVER_ERROR, | |
| res, | |
| ); | |
| } | |
| } | |
| /** | |
| * | |
| * @param query | |
| * @param res | |
| * @param req | |
| */ | |
| ('/listings/dashboard') | |
| async getDashboardLisings(() res, () req) { | |
| try { | |
| const listings = await this.propertyService.propertyRepository | |
| .find({}) | |
| .sort({ _id: -1 }) | |
| .limit(20); | |
| this.sendResponse(this.messages.Success, listings, HttpStatus.OK, res); | |
| } catch (error) { | |
| console.error('error', error); | |
| this.sendResponse( | |
| this.messages.Error, | |
| null, | |
| HttpStatus.INTERNAL_SERVER_ERROR, | |
| res, | |
| ); | |
| } | |
| } | |
| /** | |
| * | |
| * @param query | |
| * @param res | |
| * @param req | |
| */ | |
| ('/listings') | |
| async getDashboardActiveUsers(() query, () res, () req) { | |
| try { | |
| const page = Number(query.page); | |
| const resPerPage = query.resPerPage ? Number(query.resPerPage) : 20; | |
| const search = query.search || ''; // Default to empty search if not provided | |
| console.log(`search =>`, query); | |
| const listings = await this.propertyService.propertyLisitng( | |
| page, | |
| resPerPage, | |
| search, | |
| ); | |
| this.sendResponse(this.messages.Success, listings, HttpStatus.OK, res); | |
| } catch (error) { | |
| console.error('error', error); | |
| this.sendResponse( | |
| this.messages.Error, | |
| null, | |
| HttpStatus.INTERNAL_SERVER_ERROR, | |
| res, | |
| ); | |
| } | |
| } | |
| /** | |
| * | |
| * @param query | |
| * @param res | |
| * @param req | |
| */ | |
| ('/detail') | |
| async getPropertyDetails(() query, () res, () req) { | |
| try { | |
| // property id | |
| const id = query.id; | |
| const property = | |
| await this.propertyService.propertyRepository.findById(id); | |
| this.sendResponse(this.messages.Success, property, HttpStatus.OK, res); | |
| } catch (error) { | |
| console.error('error', error); | |
| this.sendResponse( | |
| this.messages.Error, | |
| null, | |
| HttpStatus.INTERNAL_SERVER_ERROR, | |
| res, | |
| ); | |
| } | |
| } | |
| } | |