A progressive Node.js framework for building efficient and scalable server-side applications.
Nest framework TypeScript starter repository.
$ pnpm install# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prod# unit tests
$ pnpm run test
# e2e tests
$ pnpm run test:e2e
# test coverage
$ pnpm run test:covWhen you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
$ pnpm install -g @nestjs/mau
$ mau deployWith Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
Check out a few resources that may come in handy when working with NestJS:
- Project docs index: docs/README.md
- Default language is PT-BR.
- To force English logs/messages, set
APP_LANG=en-USin.env. - To force Portuguese explicitly, set
APP_LANG=pt-BR.
Objetivo deste teste: validar localmente assinatura HMAC SHA-256, diferenciar eventos de GitHub App vs webhook antigo de repositório e verificar logs de aceito/ignorado/rejeitado.
- Configure a secret do webhook:
set GITHUB_WEBHOOK_SECRET=dev-webhook-secret- Suba a API:
pnpm run start:api:dev- (Opcional) verifique health do endpoint:
curl -X GET http://localhost:3000/github/webhook/health- Exemplo de payload
pushcominstallation.id(GitHub App):
{
"ref": "refs/heads/main",
"after": "1111111111111111111111111111111111111111",
"repository": {
"full_name": "acme/my-repo",
"name": "my-repo",
"owner": {
"login": "acme"
}
},
"installation": {
"id": 12345678
}
}- Gere assinatura HMAC SHA-256 com OpenSSL (PowerShell):
$secret = "dev-webhook-secret"
$body = Get-Content -Raw .\payload-app.json
$sig = "sha256=" + (([System.BitConverter]::ToString(
[System.Security.Cryptography.HMACSHA256]::new([System.Text.Encoding]::UTF8.GetBytes($secret)).ComputeHash(
[System.Text.Encoding]::UTF8.GetBytes($body)
)
)).Replace("-", "").ToLower())
$sigAlternativa com OpenSSL (bash):
SIG="sha256=$(openssl dgst -sha256 -hmac "$GITHUB_WEBHOOK_SECRET" payload-app.json | sed 's/^.* //')"
echo "$SIG"- Envie
curlcom assinatura valida einstallation.id(deve processar):
curl -X POST http://localhost:3000/github/webhook \
-H "Content-Type: application/json" \
-H "X-GitHub-Event: push" \
-H "X-GitHub-Delivery: manual-delivery-1" \
-H "X-Hub-Signature-256: $SIG" \
--data-binary @payload-app.jsonResultado esperado: HTTP 200 e logs com source=github-app e status de webhook aceito/processado.
- Exemplo de payload sem
installation.id(simula webhook antigo de repo):
{
"ref": "refs/heads/main",
"after": "2222222222222222222222222222222222222222",
"repository": {
"full_name": "acme/my-repo",
"name": "my-repo",
"owner": {
"login": "acme"
}
}
}Envie com assinatura valida para esse payload e espere HTTP 200 com log de webhook ignorado (source=repo-webhook).
- Teste assinatura invalida:
curl -X POST http://localhost:3000/github/webhook \
-H "Content-Type: application/json" \
-H "X-GitHub-Event: push" \
-H "X-GitHub-Delivery: manual-delivery-invalid" \
-H "X-Hub-Signature-256: sha256=invalid" \
--data-binary @payload-app.jsonResultado esperado: HTTP 401 e log de rejeicao por assinatura.
- Visit the NestJS Documentation to learn more about the framework.
- For questions and support, please visit our Discord channel.
- To dive deeper and get more hands-on experience, check out our official video courses.
- Deploy your application to AWS with the help of NestJS Mau in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using NestJS Devtools.
- Need help with your project (part-time to full-time)? Check out our official enterprise support.
- To stay in the loop and get updates, follow us on X and LinkedIn.
- Looking for a job, or have a job to offer? Check out our official Jobs board.
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.