NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#
# Copyright (c) 2024 The Capital Group Companies, Inc.
#

from contextlib import asynccontextmanager
from datetime import datetime
from typing import Any

import orjson
from fastapi import FastAPI, Request
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import JSONResponse
from starlette.middleware import Middleware
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.middleware.cors import CORSMiddleware

from .database import create_database_pool, destroy_database_pool
from .middleware import error_middleware, log_middleware
from .router import exposures, investors, melt_v1beta1, portfolios, sedols
from .router.investors import get_investor


class ORJSONResponse(JSONResponse):
media_type = "application/json"

def render(self, content: Any) -> bytes:
return orjson.dumps(content)


@asynccontextmanager
async def lifespan(app: FastAPI):
app.state.db_conn_pool = await create_database_pool()

yield

await destroy_database_pool(app.state.db_conn_pool)


middleware = [
Middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
]

app = FastAPI(
title="Onyx API",
contact={
"name": "Onyx",
"url": "https://quanthub.capgroup.com/",
"email": "[email protected]",
},
lifespan=lifespan,
middleware=middleware,
default_response_class=ORJSONResponse,
version="0.1.0",
)

app.add_middleware(GZipMiddleware, minimum_size=1000)
app.add_middleware(BaseHTTPMiddleware, dispatch=error_middleware)
app.add_middleware(BaseHTTPMiddleware, dispatch=log_middleware)

app.include_router(
investors.router,
prefix="/api/v1",
tags=["Investors"],
)

app.include_router(
portfolios.router,
prefix="/api/v1",
tags=["Portfolios"],
)

app.include_router(
melt_v1beta1.router,
prefix="/api/v1beta1",
tags=["Portfolios"],
)

app.include_router(
sedols.router,
prefix="/api/v1",
tags=["Security Data by SEDOL"],
)

app.include_router(
exposures.router,
prefix="/api/v1",
tags=["Exposures"],
)


@app.get("/")
async def root():
return {"message": "Onyx API is running!!"}


@app.get("/health")
async def health():
return {"message": f"Current Time : {datetime.now()}"}


@app.get("/healthCheck")
async def health_check():
res = await get_investor(Request,'01122','2024-01-31')
print('RES-->',res)


breakpoint()

result = {
"message": "API health check verified"
}
return result
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.