wip middleware

This commit is contained in:
2025-03-27 19:25:32 -03:00
parent 76c2656dd1
commit 5af61465f3
16 changed files with 422 additions and 52 deletions

View File

@@ -4,18 +4,21 @@ from http import HTTPStatus
from aws_lambda_powertools.event_handler import Response, content_types
from aws_lambda_powertools.event_handler.api_gateway import Router
from elasticsearch import Elasticsearch
from layercake.dynamodb import DynamoDBPersistenceLayer
from layercake.dynamodb import DynamoDBCollection, DynamoDBPersistenceLayer
from pydantic import BaseModel
import elastic
from boto3clients import dynamodb_client
from course import create_course
from middlewares import AuditLogMiddleware
from models import Course, Org
from settings import COURSE_TABLE, ELASTIC_CONN
from settings import COURSE_TABLE, ELASTIC_CONN, USER_TABLE
router = Router()
elastic_client = Elasticsearch(**ELASTIC_CONN)
course_layer = DynamoDBPersistenceLayer(COURSE_TABLE, dynamodb_client)
user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
collect = DynamoDBCollection(user_layer)
@router.get(
@@ -41,7 +44,12 @@ class CoursePayload(BaseModel):
course: Course
@router.post('/', compress=True, tags=['Course'])
@router.post(
'/',
compress=True,
tags=['Course'],
middlewares=[AuditLogMiddleware('COURSE_ADD', collect)],
)
def post_course(payload: CoursePayload):
create_course(
course=payload.course,