How to use the tsoa.Put function in tsoa

To help you get started, we’ve selected a few tsoa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vietnam-devs / coolstore-microservices / src / services / rating / src / controllers / ratingController.ts View on Github external
* Create a rating
   * @param request This is a rating creation request description
   */
  @Post()
  public async Create(@Body() request: RatingCreateRequest): Promise {
    console.info(request)
    let rating = new Rating({ _id: uuid.v1(), ...request })
    let result = await Rating.create(rating)
    return Promise.resolve(result)
  }

  /**
   * Update a rating
   * @param request This is a rating update request description
   */
  @Put()
  public async Update(@Body() request: RatingUpdateRequest): Promise {
    let rating = await Rating.findOne({ productId: request.productId, userId: request.userId }).exec() || {}
    if (!rating) return Promise.reject("Could not find a Product or User")
    rating = { rating, ...request }
    let result = await Rating.update(rating)
    return Promise.resolve(result)
  }
}
github MakingSense / tsoa-api / src / controllers / UserController.ts View on Github external
@Query('fields') fields?: string,
    @Query('sort') sort?: string,
    @Query('q') q?: string): Promise {
    return this.service.getPaginated(page, limit, fields, sort, q);
  }

  @Response(400, 'Bad request')
  @Security('admin')
  @Post()
  public async create(@Body() body: IUserModel): Promise {
    return this.service.create(body);
  }

  @Response(400, 'Bad request')
  @Security('admin')
  @Put('{id}')
  public async update(id: string, @Body() body: IUserModel): Promise {
    return this.service.update(id, body);
  }

  @Security('admin')
  @Delete('{id}')
  public async delete(id: string): Promise {
    return this.service.delete(id);
  }
}

tsoa

Build swagger-compliant REST APIs using TypeScript and Node

MIT
Latest version published 13 days ago

Package Health Score

92 / 100
Full package analysis