Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(authors): add authors api endpoints #23

Merged
merged 8 commits into from
Jun 8, 2021

Conversation

meretamal
Copy link
Contributor

@meretamal meretamal commented Jun 7, 2021

What?

Se implementaron dos enpoints para manejar el recurso authors

Why?

Para poder proveer parte de la aplicación como una API.

El body del response en cada caso sigue el estándar jsonapi:

{
    "data": {
        "type": "authors",
        "id": "1",
        "attributes": {
            "firstName": "Joanne",
            "lastName": "Rowling",
            "birthDate": "1965-07-31"
        }
    }
}

How?

Utilizando koa-router se creó un router con un método GET y otro POST y se usó jsonapi-serializer para serializar el response de los requests.

Anything Else? (optional)

Para probarlo es importante correr:

yarn install

@meretamal meretamal requested review from sivicencio and dhvasquez June 7, 2021 18:38
@meretamal meretamal self-assigned this Jun 7, 2021
@meretamal meretamal requested a review from dasolari June 7, 2021 18:41
@meretamal meretamal added the enhancement New feature or request label Jun 7, 2021
Copy link
Contributor

@sivicencio sivicencio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dejé algunas ideas respecto a cómo aislar las rutas de la API del resto de la aplicación.

¿Podrías además agregar en la descripción del PR un ejemplo del response body que obtienes en cada caso?

@meretamal meretamal requested a review from sivicencio June 8, 2021 04:58
Copy link
Contributor

@dasolari dasolari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si no es mucho problema, propongo un cambio que me tiró error en un test; no se valida un firstName vacío, por lo que se guarda como null en la base de datos y al esperar un post con status 400, me lo devuelve con 201 🙈 .
(Sino, hago el cambio en la PR de tests de endpoints).

@meretamal
Copy link
Contributor Author

@dasolari creo que eso debería ir en otro pull request que se encargue de agregar más validaciones al modelo de author. Puedo hacerlo en un rato

@dasolari
Copy link
Contributor

dasolari commented Jun 8, 2021

Ah perfecto. Si quieres lo hago yo (en otro PR). Avísame @meretamal

@meretamal
Copy link
Contributor Author

@dasolari dale tú entonces ❤️

@meretamal meretamal merged commit dc2e091 into main Jun 8, 2021
@sivicencio sivicencio deleted the feat/add-authors-endpoints branch July 5, 2021 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants