Notes Used to Craft this Lesson
Okay, so next we have in our PostsController a store method mimicking a post creation, along with validation.
// app/controllers/posts_controller.ts
export default class PostsController {
// ...
async store({ request, response }: HttpContext) {
const data = await request.validateUsing(postValidator)
const post = {
id: randomInt(100),
...data,
}
return response.created(post)
}
// ...
}