dguglielmi-git / innovandoliving-mercadopago-cf

Mercadopago Backend Cloud Function
2 stars 0 forks source link

Backend Migration - Favorites (Backend) #7

Open dguglielmi-git opened 1 year ago

dguglielmi-git commented 1 year ago

Endpoints required:


Routes taken from Strapi:

"routes": [
    {
      "method": "GET",
      "path": "/favorites",
      "handler": "favorite.find",
      "config": {
        "policies": []
      }
    },
    {
      "method": "GET",
      "path": "/favorites/count",
      "handler": "favorite.count",
      "config": {
        "policies": []
      }
    },
    {
      "method": "GET",
      "path": "/favorites/:id",
      "handler": "favorite.findOne",
      "config": {
        "policies": []
      }
    },
    {
      "method": "POST",
      "path": "/favorites",
      "handler": "favorite.create",
      "config": {
        "policies": []
      }
    },
    {
      "method": "PUT",
      "path": "/favorites/:id",
      "handler": "favorite.update",
      "config": {
        "policies": []
      }
    },
    {
      "method": "DELETE",
      "path": "/favorites/:id",
      "handler": "favorite.delete",
      "config": {
        "policies": []
      }
    }
  ]

Model:

"collectionName": "favorites",
  "info": {
    "name": "favorite"
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "users_permissions_user": {
      "plugin": "users-permissions",
      "model": "user"
    },
    "producto": {
      "model": "producto"
    }
  }
dguglielmi-git commented 1 year ago

We need to modify the responses from the endpoints, instead of sending the JSON with the data that is not used, we will reply only with HTTP Code. Also, the validation of the existence of a resource will be done inside the endpoint to speed up the response. Replying with a status code instead of the JSON will speed up the process since we will not be sending any data throughout the network.