How to use the routing-controllers.Delete function in routing-controllers

To help you get started, we’ve selected a few routing-controllers 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 geli-lms / geli / api / src / controllers / MediaController.ts View on Github external
}

  @Authorized(['teacher', 'admin'])
  @Delete('/directory/:id')
  async deleteDirectory(@Param('id') directoryId: string) {
    const directoryToDelete = await Directory.findById(directoryId);
    if (!directoryToDelete) {
      throw new NotFoundError();
    }
    await directoryToDelete.remove();

    return {success: true};
  }

  @Authorized(['teacher', 'admin'])
  @Delete('/file/:id')
  async deleteFile(@Param('id') fileId: string) {
    const fileToDelete = await File.findById(fileId);
    if (!fileToDelete) {
      throw new NotFoundError();
    }
    await fileToDelete.remove();

    return {success: true};
  }
}
github shanmugharajk / react-point-of-sale / api / src / controllers / user / UserController.ts View on Github external
@Body() User: User,
    @CurrentUser() userid: string
  ): Promise {
    return await this.crudServices.create(userid, User);
  }

  @Put("/:id")
  public async updateUser(
    @Param("id") id: string,
    @Body() data: User,
    @CurrentUser() userid: string
  ) {
    return await this.crudServices.updateById(userid, { id }, data);
  }

  @Delete("/:id")
  public async deleteUser(@Param("id") id: string): Promise {
    return await this.crudServices.deleteById(id);
  }
}
github ktanakaj / typeorm-example / typeorm-example / src / controllers / blog-controller.ts View on Github external
*   delete:
	 *     tags:
	 *       - blogs
	 *     summary: ブログ削除
	 *     description: ブログを削除する。
	 *     parameters:
	 *       - $ref: '#/parameters/blogIdPathParam'
	 *     responses:
	 *       200:
	 *         description: 削除成功
	 *         schema:
	 *           $ref: '#/definitions/Blog'
	 *       404:
	 *         $ref: '#/responses/NotFound'
	 */
	@Delete('/:id')
	remove(@Param('id') id: number): Promise {
		return this.blogService.delete(id);
	}
}
github shanmugharajk / react-point-of-sale / api / src / controllers / customer / CustomerController.ts View on Github external
@Body() Customer: Customer,
    @CurrentUser() userid: string
  ): Promise {
    return await this.crudServices.create(userid, Customer);
  }

  @Put("/:id")
  public async updateCustomer(
    @Param("id") id: string,
    @Body() data: Customer,
    @CurrentUser() userid: string
  ) {
    return await this.crudServices.updateById(userid, { id }, data);
  }

  @Delete("/:id")
  public async deleteCustomer(@Param("id") id: string): Promise {
    return await this.crudServices.deleteById(id);
  }
}
github shanmugharajk / react-point-of-sale / api / src / controllers / products / ProductTypesController.ts View on Github external
@Body() productType: ProductType,
    @CurrentUser() userid: string
  ): Promise {
    return await this.crudServices.create(userid, productType);
  }

  @Put('/:id')
  public async updateProductType(
    @Param('id') id: string,
    @Body() data: ProductType,
    @CurrentUser() userid: string
  ) {
    return await this.crudServices.updateById(userid, { id }, data);
  }

  @Delete('/:id')
  public async deleteProductType(@Param('id') id: string): Promise {
    return await this.crudServices.deleteById(id);
  }
}
github ChatPlug / ChatPlug / src / services / api / controllers / ConnectionsController.ts View on Github external
constructor(context: ChatPlugContext) {
    this.context = context
    this.connectionsRepository = context.connection.getRepository(ThreadConnection)
  }

  @Get('/')
  async getConnections() {
    return this.connectionsRepository.find({ deleted: false })
  }

  @Get('/:id')
  async getConnectionById(@Param('id') id : number) {
    return this.connectionsRepository.findOne({ id })
  }

  @Delete('/:id')
  async deleteConnectionById(@Param('id') id : number) {
    await this.context.connection.createQueryBuilder()
      .update(Thread)
      .set({ deleted: true })
      .where('threadConnection.id = :threadConnection', { threadConnection: id })
      .execute()
    await this.context.connection.createQueryBuilder()
      .update(Message)
      .set({ deleted: true })
      .where('threadConnection.id = :threadConnection', { threadConnection: id })
      .execute()

    return this.connectionsRepository.update({ id }, { deleted: true })
  }

  @Get('/:id/messages')
github shanmugharajk / react-point-of-sale / api / src / controllers / expenses / ExpensesController.ts View on Github external
@Body() Expense: Expense,
    @CurrentUser() userid: string
  ): Promise {
    return await this.crudServices.create(userid, Expense);
  }

  @Put("/:id")
  public async updateExpense(
    @Param("id") id: string,
    @Body() data: Expense,
    @CurrentUser() userid: string
  ) {
    return await this.crudServices.updateById(userid, { id }, data);
  }

  @Delete("/:id")
  public async deleteExpense(@Param("id") id: string): Promise {
    return await this.crudServices.deleteById(id);
  }
}
github w3tecch / express-typescript-boilerplate / src / api / controllers / UserController.ts View on Github external
@OnUndefined(UserNotFoundError)
    public one(@Param('id') id: string): Promise {
        return this.userService.findOne(id);
    }

    @Post()
    public create(@Body() user: User): Promise {
        return this.userService.create(user);
    }

    @Put('/:id')
    public update(@Param('id') id: string, @Body() user: User): Promise {
        return this.userService.update(id, user);
    }

    @Delete('/:id')
    public delete(@Param('id') id: string): Promise {
        return this.userService.delete(id);
    }

}
github ChatPlug / ChatPlug / src / services / api / controllers / ServicesController.ts View on Github external
return await this.context.connection.getRepository(Thread).find({ where: { service: { id }, deleted: false } })
  }

  @Get('/instances/:id/logs')
  async getServiceLogs(@Param('id') id: number) {
    return await this.context.connection.getRepository(Log).find({ where: { service: { id }, deleted: false } })
  }

  @Get('/instances/:id/threads/search')
  async searchServiceThreads(
    @QueryParam('query') q: string,
    @Param('id') id: number) {
    return await this.context.serviceManager.getServiceForId(id)!!.searchThreads(q)
  }

  @Delete('/instances/:id')
  async deleteService(@Param('id') id: number) {
    const foundService = await this.servicesRepository.findOne({ id })
    this.context.connection.getRepository(Log).update({ service: foundService }, { deleted: true })
    this.context.connection.getRepository(Thread).update({ service: foundService }, { deleted: true })
    this.context.connection.getRepository(User).update({ service: foundService }, { deleted: true })

    return this.servicesRepository.remove(foundService!!)
  }

  @Put('/instances/:id')
  async updateService(
    @Param('id') id: number,
    @Body() instance: any) {
    return this.servicesRepository.update({ id }, instance)
  }
github luixaviles / node-typescript-app / src / controllers / speaker.controller.ts View on Github external
@Post('/speakers')
    post(@Req() request: Request, 
         @Res() response: Response, 
         @Body() speaker: Speaker) {
        return response.send(this.repository.save(speaker));
    }

    @Put('/speakers/:id')
    put(@Req() request: Request, 
        @Res() response: Response,
        @Param('id') id: string, 
        @Body() speaker: Speaker) {
        return response.send(this.repository.update(id, speaker));
    }

    @Delete('/speakers/:id')
    remove(@Param('id') id: string) {
       return 'Removing speaker...';
    }

}