ci: add Dockerfile
This commit is contained in:
parent
72ee09b064
commit
65a56f2658
15 changed files with 382 additions and 70 deletions
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"version": "2.0",
|
||||
"app_name": "secretsanta",
|
||||
"stages": {
|
||||
"dev": {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,8 +4,8 @@ from chalice import Chalice
|
|||
from secretsanta.domain import Group
|
||||
from secretsanta.repo import S3Repo
|
||||
from secretsanta.service import (
|
||||
GetGroupParticipantsService,
|
||||
CreateGroupService,
|
||||
GetGroupParticipantsService,
|
||||
GetPairService,
|
||||
)
|
||||
from secretsanta.settings import get_config
|
||||
|
|
@ -16,13 +16,6 @@ app = Chalice(app_name="secretsanta", debug=config.environment == "local")
|
|||
repo = S3Repo()
|
||||
|
||||
|
||||
def _participants2url(participants: list[str], group_uuid: str) -> list[str]:
|
||||
return [
|
||||
f"{config.server_url}/api/v1/groups/{group_uuid}/pair/{participant_name}"
|
||||
for participant_name in participants
|
||||
]
|
||||
|
||||
|
||||
@app.route("/api/v1/groups/{group_uuid}")
|
||||
def get_participants(group_uuid: str):
|
||||
service = GetGroupParticipantsService(repo)
|
||||
|
|
@ -34,8 +27,7 @@ def create_group(group_uuid: str):
|
|||
request = app.current_request
|
||||
body = request.json_body
|
||||
service = CreateGroupService(repo)
|
||||
participants = anyio.run(service.run, Group(uuid=group_uuid, **body)).participants
|
||||
return _participants2url(participants, group_uuid)
|
||||
return anyio.run(service.run, Group(uuid=group_uuid, **body))
|
||||
|
||||
|
||||
@app.route("/api/v1/groups/{group_uuid}/pair/{participant}")
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
from dataclasses import dataclass, asdict
|
||||
from typing import Literal, Annotated
|
||||
from dataclasses import asdict, dataclass
|
||||
from typing import Annotated, Literal
|
||||
|
||||
from litestar import Controller, get, Litestar, put, Request, Response, MediaType
|
||||
from litestar import Controller, Litestar, MediaType, Request, Response, get, put
|
||||
from litestar.params import Parameter
|
||||
from pydantic import UUID4
|
||||
|
||||
from secretsanta.domain import Group
|
||||
from secretsanta.repo import S3Repo
|
||||
from secretsanta.service import (
|
||||
GetGroupParticipantsService,
|
||||
CreateGroupService,
|
||||
GetGroupParticipantsService,
|
||||
GetPairService,
|
||||
)
|
||||
from secretsanta.settings import get_config
|
||||
|
|
@ -46,10 +46,13 @@ class GroupController(Controller):
|
|||
|
||||
@put("/{group_uuid:uuid}")
|
||||
async def create_group(
|
||||
self, request: Request, group_uuid: UUID4, data: CreateGroup
|
||||
self,
|
||||
request: Request,
|
||||
group_uuid: UUID4,
|
||||
data: CreateGroup,
|
||||
) -> list[str]:
|
||||
group = await self.create_group_service.run(
|
||||
Group(uuid=group_uuid, **asdict(data))
|
||||
Group(uuid=group_uuid, **asdict(data)),
|
||||
)
|
||||
return self._group2urls(group.participants, request.url)
|
||||
|
||||
|
|
@ -59,11 +62,13 @@ class GroupController(Controller):
|
|||
group_uuid: UUID4,
|
||||
participant_name: str,
|
||||
response_type: Annotated[
|
||||
Literal["json", "plain"], Parameter(query="type")
|
||||
Literal["json", "plain"],
|
||||
Parameter(query="type"),
|
||||
] = "plain",
|
||||
) -> Response[str] | PairResponse:
|
||||
pair = await self.get_pair_service.run(
|
||||
group_uuid=group_uuid, participant=participant_name
|
||||
group_uuid=group_uuid,
|
||||
participant=participant_name,
|
||||
)
|
||||
if response_type == "json":
|
||||
return PairResponse(pair=pair)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import anyio
|
|||
from secretsanta.domain import Group
|
||||
from secretsanta.repo import S3Repo
|
||||
from secretsanta.service import (
|
||||
CreateGroupService,
|
||||
GetGroupParticipantsService,
|
||||
GetPairService,
|
||||
CreateGroupService,
|
||||
)
|
||||
from secretsanta.settings import get_config
|
||||
|
||||
|
|
|
|||
|
|
@ -26,16 +26,16 @@ custom:
|
|||
dockerizePip: true
|
||||
zip: true
|
||||
slim: true
|
||||
layer: true
|
||||
prune:
|
||||
automatic: true
|
||||
includeLayers: true
|
||||
number: 1
|
||||
apiGatewayCaching:
|
||||
enabled: true
|
||||
apiGatewayThrottling:
|
||||
maxRequestsPerSecond: 100
|
||||
maxConcurrentRequests: 5
|
||||
layer: false
|
||||
#prune:
|
||||
# automatic: true
|
||||
# includeLayers: true
|
||||
# number: 1
|
||||
#apiGatewayCaching:
|
||||
# enabled: true
|
||||
#apiGatewayThrottling:
|
||||
# maxRequestsPerSecond: 100
|
||||
# maxConcurrentRequests: 5
|
||||
|
||||
plugins:
|
||||
- serverless-python-requirements
|
||||
|
|
@ -47,27 +47,25 @@ plugins:
|
|||
functions:
|
||||
get_participants:
|
||||
handler: app.get_participants
|
||||
layers:
|
||||
- Ref: PythonRequirementsLambdaLayer
|
||||
events:
|
||||
- httpApi:
|
||||
path: /api/v1/groups/{group_uuid}
|
||||
method: get
|
||||
|
||||
create_group:
|
||||
handler: app.create_group
|
||||
layers:
|
||||
- Ref: PythonRequirementsLambdaLayer
|
||||
events:
|
||||
- httpApi:
|
||||
path: /api/v1/groups/{group_uuid}
|
||||
method: put
|
||||
#create_group:
|
||||
# handler: app.create_group
|
||||
# layers:
|
||||
# - Ref: PythonRequirementsLambdaLayer
|
||||
# events:
|
||||
# - httpApi:
|
||||
# path: /api/v1/groups/{group_uuid}
|
||||
# method: put
|
||||
|
||||
get_pair:
|
||||
handler: app.get_pair
|
||||
layers:
|
||||
- Ref: PythonRequirementsLambdaLayer
|
||||
events:
|
||||
- httpApi:
|
||||
path: /api/v1/groups/{group_uuid}/pair/{participant}
|
||||
method: get
|
||||
#get_pair:
|
||||
# handler: app.get_pair
|
||||
# layers:
|
||||
# - Ref: PythonRequirementsLambdaLayer
|
||||
# events:
|
||||
# - httpApi:
|
||||
# path: /api/v1/groups/{group_uuid}/pair/{participant}
|
||||
# method: get
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue