MCPcopy Create free account
hub / github.com/devinterface/startersaas-go-api / Me

Method Me

endpoints/user.endpoint.go:15–37  ·  view source on GitHub ↗

Me function

(ctx *fiber.Ctx)

Source from the content-addressed store, hash-verified

13
14// Me function
15func (userEndpoint *UserEndpoint) Me(ctx *fiber.Ctx) error {
16 me, err := userEndpoint.CurrentUser(ctx)
17 if err != nil {
18 return ctx.Status(401).JSON(fiber.Map{
19 "message": err.Error(),
20 })
21 }
22 showUser := models.ShowUserSerializer().Transform(me)
23
24 queryAccount := ctx.Query("withAccount")
25 if queryAccount == "true" {
26 account, err := accountService.ByID(me.AccountID)
27 if err != nil {
28 return ctx.Status(404).JSON(fiber.Map{
29 "message": err.Error(),
30 })
31 }
32 showAccount := models.ShowAccountSerializer().Transform(account)
33 showUser["account"] = showAccount
34 }
35
36 return ctx.JSON(showUser)
37}
38
39// UpdateMe function
40func (userEndpoint *UserEndpoint) UpdateMe(ctx *fiber.Ctx) error {

Callers

nothing calls this directly

Calls 4

ShowUserSerializerFunction · 0.92
ShowAccountSerializerFunction · 0.92
CurrentUserMethod · 0.80
ByIDMethod · 0.45

Tested by

no test coverage detected