-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
39 lines (33 loc) · 884 Bytes
/
main.py
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
"""Initialization fastapi application
"""
from fastapi import FastAPI, Depends
from aioredis import create_redis_pool
from neo4j import GraphDatabase, basic_auth
from utils import CONFIG
from conn.redis import RedisClient
from conn.neo4j import NeoClient
from apis import demo
from middlewares import internal_only
app = FastAPI()
@app.on_event("startup")
async def init_conns():
"""Init external connections & middlewares
"""
pool = await create_redis_pool(CONFIG['REDIS_URL'])
RedisClient(pool)
neourl = CONFIG['NEO4J_URL']
driver = GraphDatabase.driver(
neourl,
auth=basic_auth("neo4j", "test"),
encrypted=False,
)
NeoClient(driver)
app.include_router(
demo.router,
prefix="/thing",
tags=["Thing"],
# dependencies=[Depends(internal_only)],
responses={404: {
"message": "Not found"
}},
)