How to use the @tsed/common.Delete function in @tsed/common

To help you get started, we’ve selected a few @tsed/common 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 TypedProject / ts-express-decorators / test / integration / app / controllers / calendars / CalendarCtrl.ts View on Github external
@Delete("/")
  @Status(204)
  @Authenticated({role: "admin"})
  @Security("global_auth", "read:global")
  @Security("calendar_auth", "write:calendar", "read:calendar")
  public remove(
    @BodyParams("id")
    @Required()
      id: string
  ): void {

    return undefined;
  }

  @Delete("/token")
  @Status(204)
  @OAuth({role: "admin", scopes: ["write:calendar", "read:calendar"]})
  public removeWithToken(@BodyParams("id") @Required() id: string): void {

    return undefined;
  }

  /**
   *
   * @param request
   * @param auth
   * @returns {{user: (number|any|string)}}
   */
  @Get("/middleware")
  @Use(CalendarCtrl.middleware)
  public getWithMiddleware(@Request() request: any, @HeaderParams("authorization") auth: string): any {
github TypedProject / ts-express-decorators / test / integration / app / controllers / calendars / EventCtrl.ts View on Github external
*
   * @param event
   * @returns {null}
   */
  @Post("/list")
  @Authenticated({role: "admin"})
  @Returns(200, {use: EventModel, collection: Array})
  update(@BodyParams("event", EventModel) event: EventModel[]): EventModel[] {
    return event;
  }

  /**
   *
   * @returns {null}
   */
  @Delete("/:id")
  remove(): Promise<any> | void {
    return Promise.resolve(null);
  }

  /**
   *
   * @returns {null}
   */
  @Get("/status")
  byStatus(@QueryParams("status", String) status: string[]): Promise<any[]> | void {
    return Promise.resolve(status);
  }

  /**
   *
   * @returns {null}
github TypedProject / ts-express-decorators / test / integration / app / controllers / calendars / CalendarCtrl.ts View on Github external
*/
  @Put("/")
  @Returns(CalendarModel)
  public save(
    @BodyParams("name")
    @Required()
      name: string
  ): CalendarModel {
    const model = new CalendarModel();
    model.id = "2";
    model.name = "test";

    return model;
  }

  @Delete("/")
  @Status(204)
  @Authenticated({role: "admin"})
  @Security("global_auth", "read:global")
  @Security("calendar_auth", "write:calendar", "read:calendar")
  public remove(
    @BodyParams("id")
    @Required()
      id: string
  ): void {

    return undefined;
  }

  @Delete("/token")
  @Status(204)
  @OAuth({role: "admin", scopes: ["write:calendar", "read:calendar"]})
github TypedProject / ts-express-decorators / examples / getting-started / src / controllers / calendars / CalendarsCtrl.ts View on Github external
@Put("/")
  @Status(201)
  @Returns(Calendar)
  save(@BodyParams() calendar: CreateCalendar): Promise<Calendar> {
    return this.calendarsService.create(calendar);
  }

  @Post("/:id")
  @Returns(Calendar)
  async update(@PathParams("id") @Required() id: string,
               @BodyParams() @Required() calendar: CreateCalendar): Promise<Calendar> {
    return this.calendarsService.update({id, ...calendar});
  }

  @Delete("/")
  @Status(204)
  async remove(@BodyParams("id") @Required() id: string): Promise<void> {
    await this.calendarsService.remove(id);
  }

  @Get("/")
  @ReturnsArray(Calendar)
  async getAllCalendars() {
    return this.calendarsService.query();
  }
}
github TypedProject / ts-express-decorators / examples / getting-started / src / controllers / events / EventsCtrl.ts View on Github external
@Post("/:id")
  async update(@Required() @PathParams("calendarId") calendarId: string,
               @PathParams("id") id: string,
               @BodyParams("startDate") startDate: string,
               @BodyParams("endDate") endDate: string,
               @BodyParams("name") name: string): Promise<Event> {

    const event = await this.get(calendarId, id);
    event.name = name;
    event.startDate = name;
    event.endDate = name;

    return event;
  }

  @Delete("/:id")
  @Authenticated()
  @Status(204)
  async remove(@Required() @PathParams("calendarId") calendarId: string,
               @PathParams("id") id: string): Promise<void> {
    this.events = this.events.filter(event => event.id === id && event.calendarId === calendarId);
  }

  @Get("/")
  async getEvents(@Required() @PathParams("calendarId") calendarId: string): Promise<Event[]> {
    return this.events.filter(event => event.calendarId === calendarId);
  }
}
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / calendars / CalendarsCtrl.ts View on Github external
@Status(200, {description: "Success", type: Calendar})
  async update(@PathParams("id") @Required() id: string,
               @BodyParams() calendar: Calendar): Promise<Calendar> {

    calendar._id = id;

    return this.calendarsService.save
    (calendar);
  }

  /**
   *
   * @param id
   * @returns {{id: string, name: string}}
   */
  @Delete("/:id")
  @Summary("Remove a calendar.")
  @Status(204, {description: "No content"})
  async remove(@PathParams("id") id: string): Promise<void> {
    await this.calendarsService.remove(id);
  }

  @Delete("/")
  @Summary("Remove all calendars.")
  @Status(204, {description: "No content"})
  async clear(@PathParams("id") id: string): Promise<void> {
    await this.calendarsService.clear();
  }

  /**
   *
   * @returns {Promise<ICalendar[]>}
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / events / EventsCtrl.ts View on Github external
@PathParams("id") id: string,
               @BodyParams() calendarEvent: CalendarEvent): Promise<CalendarEvent> {

    return this
      .calendarEventsService
      .find(id)
      .then(() => this.calendarEventsService.save(calendarEvent))
      .catch((err) => {
        throw new NotFound("Calendar id not found");
      });
  }

  /**
   *
   */
  @Delete("/:id")
  @UseBefore(CheckCalendarIdMiddleware)
  @Summary("Remove an event")
  @Status(204, {description: "No content"})
  async remove(@Description("The calendar id of the event")
               @Required() @PathParams("calendarId") calendarId: string,
               @Description("The event id")
               @PathParams("id") id: string): Promise<void> {
    return this.calendarEventsService.remove(id);
  }

  @Get("/")
  @Summary("Get all events for a calendar")
  @Status(200, {description: "Success"})
  async getEvents(@Description("The calendar id of the event")
                  @Required() @PathParams("calendarId") calendarId: string): Promise<CalendarEvent[]> {
    return this.calendarEventsService.query(calendarId);
github TypedProject / ts-express-decorators / examples / passportjs / src / controllers / calendars / CalendarCtrl.ts View on Github external
* @param id
   * @param name
   * @returns {Promise<Calendar>}
   */
  @Post("/:id")
  async update(@PathParams("id") @Required() id: string,
               @BodyParams("name") @Required() name: string): Promise<Calendar> {
    return this.calendarsService.update({id, name});
  }

  /**
   *
   * @param id
   * @returns {{id: string, name: string}}
   */
  @Delete("/")
  @Authenticated()
  @Status(204)
  async remove(@BodyParams("id") @Required() id: string): Promise<void> {
    this.calendarsService.remove(id);
  }

  @Get("/")
  @Authenticated()
  async getAllCalendars(): Promise<Calendar[]> {
    return this.calendarsService.query();
  }
}
github TypedProject / ts-express-decorators / examples / aws / src / controllers / calendars / CalendarsCtrl.ts View on Github external
* @param id
   * @param name
   * @returns {Promise<Calendar>}
   */
  @Post("/:id")
  async update(@PathParams("id") @Required() id: string,
               @BodyParams("name") @Required() name: string): Promise<Calendar> {
    return this.calendarsService.update({id, name});
  }

  /**
   *
   * @param id
   * @returns {{id: string, name: string}}
   */
  @Delete("/")
  @Status(204)
  async remove(@BodyParams("id") @Required() id: string): Promise<void> {
    this.calendarsService.remove(id);
  }

  @Get("/")
  async getAllCalendars(): Promise<Calendar[]> {
    return this.calendarsService.query();
  }
}
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / calendars / CalendarsCtrl.ts View on Github external
(calendar);
  }

  /**
   *
   * @param id
   * @returns {{id: string, name: string}}
   */
  @Delete("/:id")
  @Summary("Remove a calendar.")
  @Status(204, {description: "No content"})
  async remove(@PathParams("id") id: string): Promise<void> {
    await this.calendarsService.remove(id);
  }

  @Delete("/")
  @Summary("Remove all calendars.")
  @Status(204, {description: "No content"})
  async clear(@PathParams("id") id: string): Promise<void> {
    await this.calendarsService.clear();
  }

  /**
   *
   * @returns {Promise<ICalendar[]>}
   */
  @Get("/")
  @Summary("Return all calendars")
  @Status(200, {description: "Success", type: Calendar, collectionType: Array})
  async getAllCalendars(): Promise<Calendar[]> {
    return this.calendarsService.query();
  }