Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* POST /post/
*/
@post('/')
public async create(ctx) {
const res = await this.service.create(ctx.request.body);
// tslint:disable-next-line: no-magic-numbers
ctx.status = 201;
ctx.body = res;
}
/**
* PATCH /post/:id
*/
@patch('/:id')
public async update(ctx) {
const id = ctx.params.id;
const updates = {
title: ctx.request.body.title,
content: ctx.request.body.content,
};
ctx.body = await this.service.update(id, updates);
}
/**
* DEL /post/:id
*/
@del('/id')
public async destroy(ctx) {
const id = parseInt(ctx.params.id, 10);
await this.service.destroy(id);