
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
lib-hero-mvc-ps
Advanced tools
API de exemplo para gerenciar Heróis usando FastAPI, SQLModel (SQLAlchemy + Pydantic), e o padrão MVC com Repository:
Depends
├─ app/
│ ├─ main.py # inicialização da app e rotas
│ ├─ database.py # engine, sessão e inicialização do schema
│ ├─ models.py # SQLModel: entidades e schemas (Create/Update/Public)
│ ├─ controllers/
│ │ └─ heroes.py # Controller (Router) da feature "heroes"
│ ├─ services/
│ │ └─ hero_service.py # Regras de negócio
│ └─ repositories/
│ └─ hero_repository.py # Acesso ao banco (CRUD)
└─ requirements.txt
requirements.txt:
fastapi==0.114.2
uvicorn[standard]==0.30.6
SQLModel==0.0.22
Para PostgreSQL, adicione também:
psycopg[binary]==3.*
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
SQLite (padrão) – já funciona sem configurar nada.
PostgreSQL:
export DATABASE_URL="postgresql+psycopg://app:app@localhost:5432/appdb"
uvicorn app.main:app --reload
Hero (tabela): id, name, secret_name?, age?HeroCreate (entrada POST)HeroUpdate (entrada PATCH, campos opcionais)HeroPublic (saída nas respostas)Base path: /heroes
| Método | Rota | Body | Resposta | Descrição |
|---|---|---|---|---|
| POST | / | HeroCreate | HeroPublic | Cria um herói |
| GET | / | — | List[HeroPublic] | Lista heróis (offset/limit) |
| GET | /{hero_id} | — | HeroPublic | Busca por ID |
| PATCH | /{hero_id} | HeroUpdate | HeroPublic | Atualiza campos parciais |
| DELETE | /{hero_id} | — | 204 No Content | Remove herói |
Criar:
curl -X POST http://127.0.0.1:8000/heroes/ \
-H "Content-Type: application/json" \
-d '{"name":"Ada","secret_name":"The Enchantress","age":28}'
Listar:
curl "http://127.0.0.1:8000/heroes/?offset=0&limit=100"
Buscar por ID:
curl http://127.0.0.1:8000/heroes/1
Atualizar (parcial):
curl -X PATCH http://127.0.0.1:8000/heroes/1 \
-H "Content-Type: application/json" \
-d '{"name":"Ada Lovelace"}'
Remover:
curl -X DELETE http://127.0.0.1:8000/heroes/1 -i
HTTP (FastAPI)
↓
Controller (app/controllers/heroes.py)
↓
Service (app/services/hero_service.py)
↓
Repository (app/repositories/hero_repository.py)
↓
DB Session (app/database.py) + SQLModel (app/models.py)
Depends.Documento Fast API : Documentação do FAST API.
FAQs
Uma lib MVC simples da Hero com banco de dados em memória.
We found that lib-hero-mvc-ps demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.