Skip to main content

Standalone

Run nexfetch-auth as a standalone service with uvicorn.

server.py
import asyncio
import uvicorn
from nexfetch_auth import nexfetch_auth
from nexfetch_auth.db.adapters.sqlalchemy import sqlalchemy_adapter


async def main():
auth = await nexfetch_auth(
secret="your-secret-key",
database=await sqlalchemy_adapter("postgresql+asyncpg://..."),
)
config = uvicorn.Config(auth.app, host="0.0.0.0", port=8000)
server = uvicorn.Server(config)
await server.serve()


if __name__ == "__main__":
asyncio.run(main())