Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
@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};
}
}
@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);
}
}
* 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);
}
}
@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);
}
}
@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);
}
}
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')
@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);
}
}
@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);
}
}
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)
}
@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...';
}
}