mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-20 23:11:35 +01:00
Working on new version of website
Signed-off-by: Arthur DANJOU <arthurdanjou@outlook.fr>
This commit is contained in:
23
app/Controllers/Http/ProfilesController.ts
Normal file
23
app/Controllers/Http/ProfilesController.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
||||
import Profile from "App/Models/Profile";
|
||||
import ProfileUpdateValidator from "App/Validators/profile/ProfileUpdateValidator";
|
||||
|
||||
export default class ProfilesController {
|
||||
|
||||
public async index ( { response }: HttpContextContract ) {
|
||||
return response.status(200).send({
|
||||
profile: await Profile.first()
|
||||
})
|
||||
}
|
||||
|
||||
public async update ( { response, request }: HttpContextContract ) {
|
||||
const profile = await Profile.firstOrFail()
|
||||
const data = await request.validate(ProfileUpdateValidator)
|
||||
await profile.merge(data).save()
|
||||
|
||||
return response.status(200).send({
|
||||
profile
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user