Skip to content

Releases: junah201/nexify

0.7.3

Choose a tag to compare

@junah201 junah201 released this 25 Mar 08:44

Internal

  • ♻️ Refactor middleware classes for improved clarity and functionality. Commit c126590 by @junah201

0.7.2

Choose a tag to compare

@junah201 junah201 released this 24 Mar 07:24

Features

Fixes

  • 🐛 Fix incorrect EndpointConfiguration declaration. Commit 0820c32 by @junah201

Docs

0.7.1

Choose a tag to compare

@junah201 junah201 released this 11 Feb 12:48
a0f45fc

Fixes

0.7.0

Choose a tag to compare

@junah201 junah201 released this 11 Feb 12:26
886d020

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
    pass

Still, you can use depends in this handler.

Features

  • ✨ Improve usability of middleware and exception handler. PR #15 by @junah201

Fixes

  • 🐛 Deepcopy the field info to prevent default value overwrite error. Commit af50e33 by @junah201

Internals

0.6.0

Choose a tag to compare

@junah201 junah201 released this 08 Feb 07:00
e53217a

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

  • ✅ Update tests for middleware and path validation. Commit 564d6c3 by @junah201
  • ✅ Refactor tests to use fixtures for app initialization. Commit 7c3ca0a by @junah201
  • ✅ Refactor path tests to use parametrize. Commit cf3c536 by @junah201

0.5.0

Choose a tag to compare

@junah201 junah201 released this 06 Feb 04:18
60aecd7

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

Internal

  • 🐛 Fix branch condition in deploy-docs workflow for main branch

0.4.0

Choose a tag to compare

@junah201 junah201 released this 04 Feb 00:57
918d88d

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

Docs

  • 📝 Add introductory materials and first-steps tutorial. Commit 9183cd0 by @junah201

0.3.1

Choose a tag to compare

@junah201 junah201 released this 01 Feb 19:19
b520716

Fixes

  • 🐛 Prevent "$ref" from being replaced with an empty string in API Gateway MOCK integration (#6). Commit e0aa404 by @junah201

Tests

0.3.0

Choose a tag to compare

@junah201 junah201 released this 01 Feb 18:13
8a55cc1

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_item

When 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

Features

Docs

Tests

0.2.2

Choose a tag to compare

@junah201 junah201 released this 30 Jan 00:41
2a27934

Fixes

  • 🐛 Add missing import deploy app in CLI initialization. PR #4 by @junah201
  • 🐛 Fix invalid match between method and resource in CloudFormation template. PR #4 by @junah201

Internal

  • ✨ Improve deploy command's output. PR #4 by @junah201
  • ♻️ Refactor internal implement of deploy command. PR #4 by @junah201