Created
March 30, 2022 17:47
-
-
Save zehpatricio/1ec48388bc8fd9061820e347af4da9bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing | |
import fastapi | |
from app.adapter.db import location_repository_impl | |
from app.domain.use_cases.location import list_location_use_case | |
from app.domain.use_cases.location import create_location_use_case | |
from app.adapter.rest import model | |
from app.adapter.rest import mapper | |
app = fastapi.FastAPI() | |
repository = location_repository_impl.LocationRepositoryImpl() | |
list_uc = list_location_use_case.ListLocationUseCase(repository) | |
create_uc = create_location_use_case.CreateLocationUseCase(repository) | |
@app.get('/locations/') | |
def list(device_id=None): | |
return list_uc.list(device_id) | |
@app.post('/locations/') | |
def create(locations: typing.List[model.Location]): | |
locations_domain = [mapper.to_domain_model(l) for l in locations] | |
return create_uc.create(locations_domain) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment