Went back to using id's for deletion (for cleaner query params)

ref #13 #17
This commit is contained in:
2020-12-09 19:41:15 +01:00
parent a068c4d318
commit df5b8ac141
6 changed files with 21 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { getConnectionManager, Repository } from 'typeorm';
import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-extensions';
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
import { UserIdsNotMatchingError, UserNotFoundError } from '../errors/UserErrors';
import { UserGroupNotFoundError } from '../errors/UserGroupErrors';
import { CreateUser } from '../models/actions/CreateUser';
@@ -76,7 +76,8 @@ export class UserController {
@ResponseSchema(ResponseEmpty, { statusCode: 204 })
@OnUndefined(204)
@OpenAPI({ description: 'Delete a specified runner (if it exists).' })
async remove(@EntityFromParam('id') user: User) {
async remove(@Param("id") id: number) {
let user = await this.userRepository.findOne({ id: id });
if (!user) {
return null;
}