Coder Social home page Coder Social logo

swapi's Introduction

StarWars Edward Forero Api

Bienvenido, este el el código para crear un api en AWS usando el framework serverless, esta api esta basada en SWAPI. En ella podras crear nuevos personajes en tu DynamoDB y consultar los personajes creados. Tambien podrás consultar personajes del API de SWAPI con los identificadores de sus campos traducidos

Obtener un personaje de starwars

URL

    </people/:id/> -- obten una persona almacenada en tu base de datos
    </swapi/people/:id/> -- obten una persona desde el api de SWAPI

Method: GET

Code: 200 Content:

{
    "anoNacimiento": "19BBY",
    "colorOjo": "blue",
    "peliculas": [
        "https: //swapi.py4e.com/api/films/1/",
        "https: //swapi.py4e.com/api/films/2/",
        "https: //swapi.py4e.com/api/films/3/",
        "https: //swapi.py4e.com/api/films/6/",
        "https: //swapi.py4e.com/api/films/7/"
    ],
    "genero": "male",
    "colorCabello": "blond",
    "altura": "172",
    "mundoNatal": "https: //swapi.py4e.com/api/planets/1/",
    "masa": "77",
    "nombre": "Luke Skywalker",
    "colorPiel": "fair",
    "creado": "2021-01-22T00: 28: 15.957Z",
    "editado": "2021-01-22T00: 28: 15.957Z",
    "especies": [
        "https: //swapi.py4e.com/api/species/1/"
    ],
    "naves": [
        "https: //swapi.py4e.com/api/starships/12/",
        "https: //swapi.py4e.com/api/starships/22/"
    ],
    "url": "https: //swapi.py4e.com/api/people/1/",
    "vehiculos": [
        "https: //swapi.py4e.com/api/vehicles/14/",
        "https: //swapi.py4e.com/api/vehicles/30/"
    ]
}
Code 404: Persona no encontrada.

Crear un personaje de starwars

URL

    </people>

Method: POST

Data Params -- todos los parametros son obligatorios

{
    "anoNacimiento": "19BBY",
    "colorOjo": "blue",
    "peliculas": [
        "https: //swapi.py4e.com/api/films/1/",
        "https: //swapi.py4e.com/api/films/2/",
        "https: //swapi.py4e.com/api/films/3/",
        "https: //swapi.py4e.com/api/films/6/",
        "https: //swapi.py4e.com/api/films/7/"
    ],
    "genero": "male",
    "colorCabello": "blond",
    "altura": "172",
    "mundoNatal": "https: //swapi.py4e.com/api/planets/1/",
    "masa": "77",
    "nombre": "Luke Skywalker",
    "colorPiel": "fair",
    "creado": "2021-01-22T00: 28: 15.957Z",
    "editado": "2021-01-22T00: 28: 15.957Z",
    "especies": [
        "https: //swapi.py4e.com/api/species/1/"
    ],
    "naves": [
        "https: //swapi.py4e.com/api/starships/12/",
        "https: //swapi.py4e.com/api/starships/22/"
    ],
    "url": "https: //swapi.py4e.com/api/people/1/",
    "vehiculos": [
        "https: //swapi.py4e.com/api/vehicles/14/",
        "https: //swapi.py4e.com/api/vehicles/30/"
    ],
    "id": 2,
    "typeData": "people"
}
Code: 200 Content:
{
    "anoNacimiento": "19BBY",
    "colorOjo": "blue",
    "peliculas": [
        "https: //swapi.py4e.com/api/films/1/",
        "https: //swapi.py4e.com/api/films/2/",
        "https: //swapi.py4e.com/api/films/3/",
        "https: //swapi.py4e.com/api/films/6/",
        "https: //swapi.py4e.com/api/films/7/"
    ],
    "genero": "male",
    "colorCabello": "blond",
    "altura": "172",
    "mundoNatal": "https: //swapi.py4e.com/api/planets/1/",
    "masa": "77",
    "nombre": "Luke Skywalker",
    "colorPiel": "fair",
    "creado": "2021-01-22T00: 28: 15.957Z",
    "editado": "2021-01-22T00: 28: 15.957Z",
    "especies": [
        "https: //swapi.py4e.com/api/species/1/"
    ],
    "naves": [
        "https: //swapi.py4e.com/api/starships/12/",
        "https: //swapi.py4e.com/api/starships/22/"
    ],
    "url": "https: //swapi.py4e.com/api/people/1/",
    "vehiculos": [
        "https: //swapi.py4e.com/api/vehicles/14/",
        "https: //swapi.py4e.com/api/vehicles/30/"
    ],
    "id": 2,
    "typeData": "people"
}

Code: 500 Content:

{ 
    status : "Descripcion del error"
}
Para desplegar este proyecto en tu cuenta AWS, no olvides:
  1. Instalar y configurar el aws-sdk
  2. Instalar serverless framework
  3. Clonar este repositorio
  4. Ingresar a la carpeta del repositorio creado e instalar los paquetes
  5. Desplegar con sls deploy

En caso de que quieras hacer cambios y probarlos localmente

Tienes a disposición algunos archivos con data de prueba, cada lambda posee su propio archivo el cual puedes probar con los siguientes comandos:

  • serverless invoke local --function peopleGetByIdFuncion --path events/event-people-get-by-id.json
  • serverless invoke local --function swapiPeopleGetByIdFuncion --path events/event-swapi-people-get-by-id.json
  • serverless invoke local --function peoplePostFuncion --path events/event-people-post.json

swapi's People

Watchers

Edward Forero avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.