{"id":31030936,"url":"https://github.com/marco0antonio0/template_nest_netlify","last_synced_at":"2026-04-13T09:31:36.513Z","repository":{"id":309068820,"uuid":"1035073206","full_name":"marco0antonio0/template_nest_netlify","owner":"marco0antonio0","description":"Ready-to-use NestJS API template for Netlify serverless environment, with a clean structure and example /api/health endpoint for a quick start.","archived":false,"fork":false,"pushed_at":"2025-09-14T01:36:36.000Z","size":318,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-29T12:47:04.436Z","etag":null,"topics":["api","nestjs","nestjs-backend","netlify","nodejs","server","serverless","ts","typescript"],"latest_commit_sha":null,"homepage":"https://template-nestjs.netlify.app/api/health","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marco0antonio0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-09T15:44:16.000Z","updated_at":"2025-09-14T01:36:38.000Z","dependencies_parsed_at":"2025-08-09T23:32:13.555Z","dependency_job_id":null,"html_url":"https://github.com/marco0antonio0/template_nest_netlify","commit_stats":null,"previous_names":["marco0antonio0/teste_api_serverless"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/marco0antonio0/template_nest_netlify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marco0antonio0%2Ftemplate_nest_netlify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marco0antonio0%2Ftemplate_nest_netlify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marco0antonio0%2Ftemplate_nest_netlify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marco0antonio0%2Ftemplate_nest_netlify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marco0antonio0","download_url":"https://codeload.github.com/marco0antonio0/template_nest_netlify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marco0antonio0%2Ftemplate_nest_netlify/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31746292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","nestjs","nestjs-backend","netlify","nodejs","server","serverless","ts","typescript"],"created_at":"2025-09-13T23:52:51.373Z","updated_at":"2026-04-13T09:31:36.496Z","avatar_url":"https://github.com/marco0antonio0.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 NestJS Template for Netlify\n\u003cdiv style=\"display: flex; flex-direction: row; gap: 10px; align-items: center; margin-bottom: 20px;\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Netlify-00C7B7?style=for-the-badge\u0026logo=netlify\u0026logoColor=white\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge\u0026logo=typescript\u0026logoColor=white\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge\u0026logo=javascript\u0026logoColor=black\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Serverless-FD5750?style=for-the-badge\u0026logo=serverless\u0026logoColor=white\"\u003e\n\u003c/div\u003e\n\n- [View pt-br version](#template-nestjs-para-netlify)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://nestjs.com/\" target=\"blank\"\u003e\u003cimg src=\"https://nestjs.com/img/logo-small.svg\" width=\"120\" alt=\"Nest Logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n👋 **Welcome!**  \nThis project is a **ready-to-use template** for building APIs with **NestJS** and running them in a **serverless** environment on [Netlify](https://www.netlify.com/).  \nThe goal is to provide a clean, simple, and functional starting point so you can start quickly:  \n- All endpoints are under `/api/...`\n- Comes with an example endpoint `/api/health` that returns the application status\n- Well-organized and easy-to-extend structure\n\n---\n\u003e ---\n\u003e\n\u003e Example: [https://template-nestjs.netlify.app/api/health](https://template-nestjs.netlify.app/api/health)\n\u003e\n\u003e ---\n\n## 🚀 How to use this template\n\nCreate a new project using this template:\n\n```bash\nnpx degit marco0antonio0/template_nest_netlify my-project\n```\n\nInstall dependencies:\n\n```bash\ncd my-project\nnpm install\n```\n\nRun locally with Netlify CLI:\n\n```bash\nnpm install -g netlify-cli\nnpm run build\nnetlify dev\n```\n\n---\n\n## 📂 File Structure\n\n### `src/main.ts`\n```ts\nimport { NestFactory } from '@nestjs/core';\nimport { AppModule } from './app.module';\n\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule);\n  await app.listen(process.env.PORT ?? 3000);\n}\nbootstrap();\n```\n\u003e **Purpose**: Default NestJS entry point for local execution (`npm run start:dev`).  \n\u003e On Netlify, it is not used directly because the bootstrap is done in `netlify/functions/nest.ts`.\n\n---\n\n### `netlify/functions/nest.ts`\n```ts\nimport 'reflect-metadata';\nimport { NestFactory } from '@nestjs/core';\nimport { ExpressAdapter } from '@nestjs/platform-express';\nimport express from 'express';\nimport serverless from 'serverless-http';\nimport { AppModule } from '../../src/app.module';\n```\n\u003e **Purpose**:  \n\u003e - Adapts the NestJS app to run in a **serverless** environment using `serverless-http`.  \n\u003e - Sets `app.setGlobalPrefix('api')` so all endpoints are under `/api/...`.  \n\u003e - Uses caching to avoid recreating the server on each invocation (improves warm start performance).  \n\u003e - Exports `handler`, which is the function Netlify calls for each request.\n\n---\n\n### `src/app.module.ts`\n```ts\nimport { Module } from '@nestjs/common';\nimport { AppController } from './app.controller';\nimport { AppService } from './app.service';\n\n@Module({\n  imports: [],\n  controllers: [AppController],\n  providers: [AppService],\n})\nexport class AppModule {}\n```\n\u003e **Purpose**: Root module of the NestJS app.  \n\u003e - Registers controllers and providers.  \n\u003e - In this template, only `AppController` and `AppService` are configured.\n\n---\n\n### `src/app.controller.ts`\n```ts\nimport { Controller, Get } from '@nestjs/common';\n\n@Controller()\nexport class AppController {\n  @Get('health')\n  getHeath() {\n    return { status: 'up' };\n  }\n}\n```\n\u003e **Purpose**:  \n\u003e - Defines application routes.  \n\u003e - In this template, it has a `GET /api/health` route that returns `{ status: 'up' }` as an example.\n\n---\n\n## 🔗 Default endpoints in the template\n- **GET `/api/health`** → Returns the API status.\n\n---\n\n## 🛠️ Technologies used\n- [NestJS](https://nestjs.com/) — Progressive Node.js framework.\n- [Express](https://expressjs.com/) — HTTP server used by NestJS.\n- [serverless-http](https://github.com/dougmoscrop/serverless-http) — Adapts Express for serverless environments.\n- [Netlify Functions](https://docs.netlify.com/functions/overview/) — Netlify's serverless functions.\n\n---\n\n## 📌 Notes\n- To add new routes, create new **controllers** in `src/` and they will be automatically available under the `/api/` prefix.\n- In production, **Netlify** uses the `netlify/functions/nest.ts` file as the entry point.\n- To change the `/api` prefix, update `app.setGlobalPrefix()` in `netlify/functions/nest.ts` and `netlify.toml`.\n\n---\n\n# Template NestJS para Netlify\n\u003cdiv style=\"display: flex; flex-direction: row; gap: 10px; align-items: center; margin-bottom: 20px;\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Netlify-00C7B7?style=for-the-badge\u0026logo=netlify\u0026logoColor=white\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge\u0026logo=typescript\u0026logoColor=white\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge\u0026logo=javascript\u0026logoColor=black\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Serverless-FD5750?style=for-the-badge\u0026logo=serverless\u0026logoColor=white\"\u003e\n\u003c/div\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://nestjs.com/\" target=\"blank\"\u003e\u003cimg src=\"https://nestjs.com/img/logo-small.svg\" width=\"120\" alt=\"Nest Logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n👋 **Bem-vindo(a)!**  \nEste projeto é um **template pronto** para você criar APIs usando **NestJS** e rodá-las de forma **serverless** na plataforma [Netlify](https://www.netlify.com/).  \nA ideia é fornecer uma base limpa, simples e funcional para que você possa começar rápido:  \n- Todos os endpoints ficam sob `/api/...`\n- Já vem com um endpoint de exemplo `/api/health` que retorna o status da aplicação\n- Estrutura organizada e fácil de expandir\n\n---\n\u003e ---\n\u003e\n\u003e Exemplo: [https://template-nestjs.netlify.app/api/health](https://template-nestjs.netlify.app/api/health)\n\u003e\n\u003e ---\n\n## 🚀 Como usar este template\n\nPara criar um novo projeto usando este template:\n\n```bash\nnpx degit marco0antonio0/template_nest_netlify meu-projeto\n```\n\nInstale as dependências:\n\n```bash\ncd meu-projeto\nnpm install\n```\n\nPara rodar localmente com o Netlify CLI:\n\n```bash\nnpm install -g netlify-cli\nnetlify dev\n```\n\n---\n\n## 📂 Estrutura de Arquivos\n\n### `src/main.ts`\n```ts\nimport { NestFactory } from '@nestjs/core';\nimport { AppModule } from './app.module';\n\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule);\n  await app.listen(process.env.PORT ?? 3000);\n}\nbootstrap();\n```\n\u003e **Função**: Arquivo de entrada padrão do NestJS para execução local (`npm run start:dev`).  \n\u003e No Netlify, não é utilizado diretamente, pois o bootstrap é feito pelo `netlify/functions/nest.ts`.\n\n---\n\n### `netlify/functions/nest.ts`\n```ts\nimport 'reflect-metadata';\nimport { NestFactory } from '@nestjs/core';\nimport { ExpressAdapter } from '@nestjs/platform-express';\nimport express from 'express';\nimport serverless from 'serverless-http';\nimport { AppModule } from '../../src/app.module';\n```\n\u003e **Função**:  \n\u003e - Adapta a aplicação NestJS para rodar no formato **serverless** usando `serverless-http`.  \n\u003e - Define `app.setGlobalPrefix('api')` para que todos os endpoints fiquem sob `/api/...`.  \n\u003e - Usa cache para evitar recriar o servidor a cada invocação (melhorando performance).  \n\u003e - Exporta `handler`, que é a função que o Netlify invoca para cada requisição.\n\n---\n\n### `src/app.module.ts`\n```ts\nimport { Module } from '@nestjs/common';\nimport { AppController } from './app.controller';\nimport { AppService } from './app.service';\n\n@Module({\n  imports: [],\n  controllers: [AppController],\n  providers: [AppService],\n})\nexport class AppModule {}\n```\n\u003e **Função**: Módulo raiz do NestJS.  \n\u003e - Registra controladores (`controllers`) e provedores (`providers`).  \n\u003e - No template, apenas o `AppController` e `AppService` estão configurados.\n\n---\n\n### `src/app.controller.ts`\n```ts\nimport { Controller, Get } from '@nestjs/common';\n\n@Controller()\nexport class AppController {\n  @Get('health')\n  getHeath() {\n    return { status: 'up' };\n  }\n}\n```\n\u003e **Função**:  \n\u003e - Define as rotas da aplicação.  \n\u003e - Neste template, há uma rota `GET /api/health` que retorna `{ status: 'up' }` como exemplo.\n\n---\n\n## 🔗 Endpoints padrão no template\n- **GET `/api/health`** → Retorna status da API.\n\n---\n\n## 🛠️ Tecnologias utilizadas\n- [NestJS](https://nestjs.com/) — Framework Node.js progressivo.\n- [Express](https://expressjs.com/) — Servidor HTTP usado pelo NestJS.\n- [serverless-http](https://github.com/dougmoscrop/serverless-http) — Adapta Express para ambientes serverless.\n- [Netlify Functions](https://docs.netlify.com/functions/overview/) — Funções serverless da Netlify.\n\n---\n\n## 📌 Observações\n- Para adicionar novas rotas, crie novos **controllers** no `src/` e eles estarão automaticamente disponíveis sob o prefixo `/api/`.\n- Para produção, o **Netlify** usará o arquivo `netlify/functions/nest.ts` como ponto de entrada.\n- Se quiser mudar o prefixo `/api`, altere o `app.setGlobalPrefix()` no `netlify/functions/nest.ts` e o `netlify.toml`.\n\n---","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarco0antonio0%2Ftemplate_nest_netlify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarco0antonio0%2Ftemplate_nest_netlify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarco0antonio0%2Ftemplate_nest_netlify/lists"}