Pi66

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

← back to log

api: add API singleton with GlobalStore and expose decorator

author: pi66
date: 2026-07-21 10:13
hash: 0e791dde7e86ed490f433f325b87b5e0ee9f023f

Diffstat:

A

src/api.py
19 ++++++++++++++++++++++++++++++
 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
diff --git a/src/api.py b/src/api.py
new file mode 100644
index 0000000..4309730
--- /dev/null
+++ b/src/api.py
@@ -0,0 +1,19 @@
+"""Bridge between merodi core and user plugins"""
+
+class GlobalStore:
+    def __init__(self):
+        self.data = {}
+
+class API:
+    def __init__(self):
+        self.globals = GlobalStore()
+        self.log = None
+        self.config = None
+
+api = API()
+
+def expose(name):
+    def decorator(fn):
+        setattr(api, name, fn)
+        return fn
+    return decorator