This file contains hidden or 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
# Base image | |
FROM python:3.9 | |
# Set environment varibles | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 | |
WORKDIR /app | |
COPY requirements.txt /app/requirements.txt |
This file contains hidden or 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 uvicorn | |
from fastapi import FastAPI | |
from app.internal.db import initialize_db | |
from app.domain.recipes import RecipesDomain | |
from app.repository.recipes import RecipesRepository | |
from app.routers.recipes import RecipesRouter | |
This file contains hidden or 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
from fastapi import APIRouter | |
from fastapi import HTTPException | |
from app.domain.recipes import RecipesDomain, RecipesModel | |
class RecipesRouter: | |
def __init__(self, recipes_domain: RecipesDomain) -> None: | |
self.__recipes_domain = recipes_domain |
This file contains hidden or 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
from uuid import uuid4 | |
from pydantic import Field | |
from decimal import Decimal | |
from pydantic import BaseModel | |
from pydantic.types import UUID4 | |
from typing import List, Optional | |
from app.repository.recipes import RecipesRepository | |
class Ingredients(BaseModel): |
This file contains hidden or 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
from botocore.exceptions import ClientError | |
from boto3.resources.base import ServiceResource | |
class RecipesRepository: | |
def __init__(self, db: ServiceResource) -> None: | |
self.__db = db # db resource will be injected when this repository is created in the main.py | |
def get_all(self): | |
table = self.__db.Table('Recipes') # referencing to table Recipes | |
response = table.scan() # scan all data |
This file contains hidden or 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 boto3 | |
from boto3.resources.base import ServiceResource | |
def initialize_db() -> ServiceResource: | |
ddb = boto3.resource('dynamodb', | |
endpoint_url='http://localhost:8000', | |
region_name='example', | |
aws_access_key_id='example', | |
aws_secret_access_key='example') |
This file contains hidden or 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
FROM node:12.16.1 | |
WORKDIR /app | |
RUN npm install -g dynamodb-admin | |
CMD ["dynamodb-admin"] |
This file contains hidden or 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
version: '3.8' | |
services: | |
app: | |
build: . | |
volumes: | |
- "./:/app" | |
ports: | |
- "5000:5000" | |
depends_on: | |
- db |
This file contains hidden or 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 uvicorn | |
from fastapi import FastAPI | |
app = FastAPI() | |
@app.get('/') | |
def index(): | |
return 'Hello World!' | |
if __name__ == '__main__': |
This file contains hidden or 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
Show hidden characters
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | |
// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/go | |
{ | |
"name": "Go", | |
"dockerComposeFile": "docker-compose.yaml", | |
"service": "app", | |
"workspaceFolder": "/workspace/containerized-dev", | |
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], | |
// Set *default* container specific settings.json values on container create. |