swadhinbiswas fix: remove highlight.js CSS import causing Docker build failure · 7/20/2026
299a084
49 lines · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""shop.config — application instance, database wiring, and shared state.

The JustAPI Runtime binds handlers to a single `JustAPIApp` instance and the
DB pool is reached through `app.db`. We keep both here as package-level singletons
so handler modules can import them without a circular dependency on the app
module that registers routes.
"""
from __future__ import annotations

import os

from justapi import JustAPIApp

HERE = os.path.dirname(os.path.abspath(__file__))
SHOP_DB = os.environ.get("DEMO_SHOP_DB", os.path.join(HERE, "..", "shop.db"))


def create_app() -> JustAPIApp:
    """Build the JustAPIApp, wire the owned SQLite database, and return it.

    Route handlers are registered by importing the handler modules (their
    decorators run at import time against this same `app` instance).
    """
    application = JustAPIApp()
    # Owned, writable database (seeded from Olist by db_setup.py). The framework's
    # wal=True path is exercised separately (ADR-068); plain journal here so the
    # demo runs anywhere without that flag.
    application.set_database(f"sqlite://{SHOP_DB}")
    application.connect_database()
    return application


# Single application instance for the process.
app = create_app()


def db():
    """Return the live connection-pool handle (justapi Database)."""
    return app.db


# Import handler modules *after* `app` and `db` exist so their decorators
# register on the app and their `from .config import app, db` resolves.
from . import catalog  # noqa: E402,F401
from . import customers  # noqa: E402,F401
from . import cart  # noqa: E402,F401
from . import orders  # noqa: E402,F401
from . import reviews  # noqa: E402,F401