File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import asyncio
22
33from fastapi import APIRouter
4- from lnbits .db import Database
54from loguru import logger
65
6+ from .crud import db
77from .tasks import wait_for_paid_invoices
88from .views import example_ext_generic
99from .views_api import example_ext_api
1010
11- db = Database ("ext_example" )
12-
13- scheduled_tasks : list [asyncio .Task ] = []
14-
1511example_ext : APIRouter = APIRouter (prefix = "/example" , tags = ["example" ])
1612example_ext .include_router (example_ext_generic )
1713example_ext .include_router (example_ext_api )
2319 }
2420]
2521
22+ scheduled_tasks : list [asyncio .Task ] = []
23+
2624
2725def example_stop ():
2826 for task in scheduled_tasks :
@@ -37,3 +35,12 @@ def example_start():
3735
3836 task = create_permanent_unique_task ("ext_testing" , wait_for_paid_invoices )
3937 scheduled_tasks .append (task )
38+
39+
40+ __all__ = [
41+ "db" ,
42+ "example_ext" ,
43+ "example_static_files" ,
44+ "example_start" ,
45+ "example_stop" ,
46+ ]
Original file line number Diff line number Diff line change 11# crud.py is for communication with your extensions database
22
33# add your dependencies here
4+ # from .models import createExample, Example
5+ from lnbits .db import Database
6+
7+ db = Database ("ext_example" )
48
59# add your fnctions here
10+
11+ # async def create_a_record(data: Example) -> createExample:
12+ # example_id = urlsafe_short_hash()
13+ # example = Example(id=example_id, **data.dict())
14+ # await db.insert("example.example", example)
15+ # return example
16+
17+
18+ # async def get_a_record(example_id: str) -> Optional[Example]:
19+ # return await db.fetchone(
20+ # "SELECT * FROM example.example WHERE id = :id", {"id": example_id}, Example
21+ # )
Original file line number Diff line number Diff line change 44class Example (BaseModel ):
55 id : str
66 wallet : str
7+
8+
9+ class CreateExample (BaseModel ):
10+ wallet : str
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ window.app = Vue.createApp({
2222 tab : 'frameworks' ,
2323 framworktab : 'fastapi' ,
2424 usefultab : 'magicalg' ,
25- vettedData : ''
25+ vettedData : '' ,
26+ baseUrl : window . location . origin
2627 }
2728 } ,
2829 // Where functions live
@@ -36,7 +37,7 @@ window.app = Vue.createApp({
3637 data
3738 )
3839 . then ( response => {
39- this . exampleData = response . data . map ( mapObject ) // Often whats returned is mapped onto some model
40+ this . exampleData . push ( mapObject ( response . data ) ) // Often whats returned is mapped onto some model
4041 } )
4142 // Error will be passed to the frontend
4243 . catch ( LNbits . utils . notifyApiError )
You can’t perform that action at this time.
0 commit comments