Repository navigation
Releases: junah201/nexify
Release list
0.7.3
0.7.2
0.7.1
0.7.0
Highlight
Schedule Triggers
Now, you can add schedule trigger such as cron job
from typing import Annotated
from nexify import Nexify, Event
from nexify.schedule import Rate
app = Nexify()
@app.schedule(Rate(5, Rate.MINUTES))
def my_handler(event: Annotated[dict, Event()]):
# DO SOMETHING
passStill, you can use depends in this handler.
Features
Fixes
Internals
0.6.0
Highlight
Depends
Now, Nexify has a very powerful Dependency Injection system.
def common_parameters(
q: Annotated[str | None, Query()] = None,
skip: Annotated[int, Query()] = 0,
limit: Annotated[int, Query()] = 100,
):
return {"q": q, "skip": skip, "limit": limit}
@app.get("/items")
def read_items(
common: Annotated[dict, Depends(common_parameters)],
):
...Also, we supports dependencies that do some extra steps after finishing.
To do this, use yield instead of return, and write the extra steps (code) in the finally scope.
def get_db():
db = Session()
try:
yield db
finally:
db.close()
@app.get("/user")
def read_user(db: Annotated[Session, Depends(get_db)]):This is very similar to Depends in FastAPI.
Header and Cookie
In Nexify, you can extract values from request headers and cookies using Header and Cookie dependencies.
@app.get("/headers")
def read_headers(user_agent: Annotated[str, Header()], x_token: Annotated[str, Header()]) -> dict:
return {"User-Agent": user_agent, "X-Token": x_token}Similarly, you can extract cookies like this:
@app.get("/cookies")
def read_cookies(session_id: Annotated[str, Cookie()]) -> dict:
return {"Session-ID": session_id}Features
Tests
0.5.0
Highlight
Middleware
You can add your custom middleware, like this:
import json
from nexify import Nexify
from nexify.responses import JSONResponse
def custom_my_middleware(route, event, context, call_next, **kwargs):
response = call_next(event, context, **kwargs)
response.headers["x-custom-header"] = "Custom Value"
return response
app = Nexify(middlewares=[custom_my_middleware])
@app.get("/items")
def read_items():
return JSONResponse(content={"items": [{"name": "Item One"}, {"name": "Item Two"}]})Features
Fixes
- 🐛 Ensure .nexify directory exists before writing OpenAPI and template files. Commit e964f47 by @junah201
- 🐛 Fix OpenAPI JSON serialization by using deepcopy to prevent mutation. Commit 61a335d by @junah201
Docs
- 📝 Add path parameters tutorial. Commit 0ea1891 by @junah201
- 📝 Add query parameters tutorial. Commit 32f7940 by @junah201
- 📝 Add request body tutorial. Commit d443c76 by @junah201
- 📝 Add path and query validation and extra information tutorial. Commit 661726f by @junah201
- 📝 Add body fields tutorial. Commit fd4b3bb by @junah201
Internal
- 🐛 Fix branch condition in deploy-docs workflow for main branch
0.4.0
Highlight
Error handling
Now, you can add your custom error handler, like this:
from nexify import Nexify
class YourCustomException(Exception):
pass
def custom_exception_handler(event, context, e):
return {"statusCode": 400, "body": str(e)}
app = Nexify(exception_handlers={YourCustomException: custom_exception_handler})Also, Nexify have default handler for HTTPException, RequestValidationError, ResponseValidationError.
app = Nexify()
@app.get("/items/{id}")
def read_item(id: Annotated[int, Path()]): ...For example, if you sent a request to items/foo, you would receive a response like this:
{
"detail": [
{
"type": "int_parsing",
"loc": ["path", "id"],
"msg": "Input should be a valid integer, unable to parse string as an integer",
"input": "foo",
}
]
}Features
Fixes
- 🐛 Fix invalid resource creation for root path. Commit 12c24dd by @junah201
- 🐛 Fix invalid log group name in template. Commit ae75f63 by @junah201
Docs
0.3.1
0.3.0
Highlight
Swagger and ReDoc
Now, Nexify generates resources and methods for Swagger and ReDoc when you deploy it.
So you can use auto-generated Swagger and ReDoc without having to set them up.
$ nexify deploy
✔ App imported successfully!
✔ Config loaded successfully!
✔ App analyzed successfully!
✔ Requirements installed successfully!
✔ Lambda functions packaged successfully!
✔ Basic stack created successfully!
✔ Template created successfully!
✔ Stack updated successfully!
🎉 Deployment successful!
Endpoints:
- GET https://apigatewayid.execute-api.ap-northeast-2.amazonaws.com/prod/items
- POST https://apigatewayid.execute-api.ap-northeast-2.amazonaws.com/prod/items
- GET https://apigatewayid.execute-api.ap-northeast-2.amazonaws.com/prod/items/{item_id}
API Docs:
- openapi https://apigatewayid.execute-api.ap-northeast-2.amazonaws.com/prod/openapi.json
- Swagger https://apigatewayid.execute-api.ap-northeast-2.amazonaws.com/prod/docs
- ReDoc https://apigatewayid.execute-api.ap-northeast-2.amazonaws.com/prod/redoc
Functions:
- read_items
- create_item
- read_itemWhen you run nexify deploy, Nexify provides the URLs of Swagger and ReDoc as output.
Official Documentation
Now, we have official documentation for Nexify.
You can check it out at nexify.junah.dev