Skip to content

iibalena/node-project-builder

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

Description

Nest framework TypeScript starter repository.

Project setup

$ pnpm install

Compile and run the project

# development
$ pnpm run start

# watch mode
$ pnpm run start:dev

# production mode
$ pnpm run start:prod

Run tests

# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov

Deployment

When 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 deploy

With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.

Resources

Check out a few resources that may come in handy when working with NestJS:

Localization (logs/messages)

  • Default language is PT-BR.
  • To force English logs/messages, set APP_LANG=en-US in .env.
  • To force Portuguese explicitly, set APP_LANG=pt-BR.

Teste manual do webhook GitHub App

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.

  1. Configure a secret do webhook:
set GITHUB_WEBHOOK_SECRET=dev-webhook-secret
  1. Suba a API:
pnpm run start:api:dev
  1. (Opcional) verifique health do endpoint:
curl -X GET http://localhost:3000/github/webhook/health
  1. Exemplo de payload push com installation.id (GitHub App):
{
  "ref": "refs/heads/main",
  "after": "1111111111111111111111111111111111111111",
  "repository": {
    "full_name": "acme/my-repo",
    "name": "my-repo",
    "owner": {
      "login": "acme"
    }
  },
  "installation": {
    "id": 12345678
  }
}
  1. 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())
$sig

Alternativa com OpenSSL (bash):

SIG="sha256=$(openssl dgst -sha256 -hmac "$GITHUB_WEBHOOK_SECRET" payload-app.json | sed 's/^.* //')"
echo "$SIG"
  1. Envie curl com assinatura valida e installation.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.json

Resultado esperado: HTTP 200 e logs com source=github-app e status de webhook aceito/processado.

  1. 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).

  1. 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.json

Resultado 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.

Support

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.

Stay in touch

License

Nest is MIT licensed.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages