-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
140 additions
and
58 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,26 @@ | ||
import os | ||
from collections.abc import AsyncGenerator | ||
|
||
from sqlalchemy.ext.asyncio import ( | ||
AsyncSession, | ||
async_sessionmaker, | ||
create_async_engine, | ||
AsyncEngine, | ||
) | ||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine | ||
|
||
from app.auth.models import Role # noqa: F401 | ||
from app.file_transfer.models import File, Webhook # noqa: F401 | ||
from app.models import Base | ||
|
||
engine: AsyncEngine | None = None | ||
SQLALCHEMY_DATABASE_URL = os.getenv("DATABASE_URL") | ||
|
||
|
||
def get_engine() -> AsyncEngine: | ||
global engine # noqa: PLW0603 | ||
|
||
if SQLALCHEMY_DATABASE_URL is None: | ||
raise ValueError("DATABASE_URL environment variable is not set") | ||
|
||
if engine is None: | ||
engine = create_async_engine(SQLALCHEMY_DATABASE_URL, echo=True) | ||
return engine | ||
|
||
|
||
async_session_maker: None | async_sessionmaker = None | ||
|
||
|
||
def get_session_maker() -> async_sessionmaker: | ||
global async_session_maker # noqa: PLW0603 | ||
if async_session_maker is None: | ||
async_session_maker = async_sessionmaker( | ||
autocommit=False, autoflush=False, bind=get_engine(), expire_on_commit=False | ||
) | ||
return async_session_maker | ||
engine = create_async_engine(SQLALCHEMY_DATABASE_URL, echo=True) | ||
async_session_maker = async_sessionmaker( | ||
autocommit=False, autoflush=False, bind=engine, expire_on_commit=False | ||
) | ||
|
||
|
||
async def initialize_database() -> None: | ||
async with get_engine().begin() as conn: | ||
async with engine.begin() as conn: | ||
await conn.run_sync(Base.metadata.drop_all) | ||
await conn.run_sync(Base.metadata.create_all) | ||
|
||
|
||
async def get_async_session() -> AsyncGenerator[AsyncSession, None]: | ||
async with get_session_maker() as session: # type: ignore | ||
async with async_session_maker() as session: # type: ignore | ||
yield session |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ services: | |
container_name: synthra-frontend | ||
restart: unless-stopped | ||
ports: | ||
- "5002:5000" | ||
- "4173:4173" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- Header.svelte --> | ||
|
||
<header> | ||
<h1>Synthra</h1> | ||
</header> | ||
|
||
<style> | ||
header { | ||
text-align: start; | ||
margin: 5; | ||
border-bottom: 1px solid gray; | ||
padding: 10px | ||
} | ||
h1 { | ||
margin: 0; | ||
} | ||
</style> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
// place files you want to import through the `$lib` alias in this folder. | ||
import Header from './components/Header.svelte' | ||
|
||
export {Header} |
Oops, something went wrong.