-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
63 lines (53 loc) · 1.68 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from dotenv import load_dotenv
import logging, os
# Load Environment variables
load_dotenv()
# Used to silence Bcrypt warning log
logging.getLogger("passlib").setLevel(logging.ERROR)
# Router imports
from routes.root import rootRouter
from routes.url import urlRouter
from routes.user import userRouter
# Database functions
from database.connection import engine, Base
from database.databaseUtil import db_dependency
apiParams = {
"debug": os.environ.get("DEBUG", False),
"title": "SwiftBit API",
"summary": "SwiftBit is a FastAPI powered service that can shorten your urls.",
"version": "1.0.1",
"openapi_tags": [
{
"name": "Root",
"description": "Root operations. Check health or input shortened URL to redirect.",
},
{
"name": "Users",
"description": "User level operations.",
},
{
"name": "Urls",
"description": "Create and manage short URLs.",
},
],
"contact": {
"name": "MacWeTT",
"url": "https://github.com/MacWeTT",
"email": "manasbajpai18@gmail.com",
},
"license_info": {
"name": "MIT License",
"url": "https://github.com/MacWeTT/SwiftBit/blob/main/LICENSE.txt",
},
"swagger_ui_parameters": {"defaultModelsExpandDepth": -1},
}
# Application Initialization
Base.metadata.create_all(bind=engine)
app = FastAPI(**apiParams)
app.middleware(CORSMiddleware)
# Router Initialization
app.include_router(rootRouter, tags=["Root"])
app.include_router(urlRouter, tags=["Urls"])
app.include_router(userRouter, tags=["Users"])