{"id":29133131,"url":"https://github.com/iibalena/nestjs-api-i18n-auth-starter","last_synced_at":"2026-04-29T06:37:28.411Z","repository":{"id":298408733,"uuid":"999876948","full_name":"iibalena/nestjs-api-i18n-auth-starter","owner":"iibalena","description":"Starter project for building multilingual REST APIs with NestJS — includes i18next integration, validation, and Google OAuth.","archived":false,"fork":false,"pushed_at":"2025-06-11T00:01:41.000Z","size":48,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-11T01:18:52.090Z","etag":null,"topics":["api-template","google-oauth","i18n","i18next","nestjs","nestjs-i18n","nestjs-starter","nestjs-starter-template","nestjs-template","rest-api","validation"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iibalena.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-06-10T23:46:56.000Z","updated_at":"2025-06-11T00:05:00.000Z","dependencies_parsed_at":"2025-06-11T01:18:56.775Z","dependency_job_id":"1c42a9ae-cf7c-45e2-8315-c2a59835e43f","html_url":"https://github.com/iibalena/nestjs-api-i18n-auth-starter","commit_stats":null,"previous_names":["iibalena/nestjs-api-i18n-auth-starter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iibalena/nestjs-api-i18n-auth-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iibalena%2Fnestjs-api-i18n-auth-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iibalena%2Fnestjs-api-i18n-auth-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iibalena%2Fnestjs-api-i18n-auth-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iibalena%2Fnestjs-api-i18n-auth-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iibalena","download_url":"https://codeload.github.com/iibalena/nestjs-api-i18n-auth-starter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iibalena%2Fnestjs-api-i18n-auth-starter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262727707,"owners_count":23354665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-template","google-oauth","i18n","i18next","nestjs","nestjs-i18n","nestjs-starter","nestjs-starter-template","nestjs-template","rest-api","validation"],"created_at":"2025-06-30T07:02:01.797Z","updated_at":"2026-04-29T06:37:23.392Z","avatar_url":"https://github.com/iibalena.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nestjs-api-i18n-auth-starter\n\nA modern, ready-to-use starter project for building multilingual, well-structured REST APIs with NestJS.\n\n✨ **Features:**\n\n- 🌐 Internationalization (i18n) using [i18next](https://www.i18next.com/)\n- ✅ Centralized validation error handling with dynamic message interpolation\n- 🛡️ Global `HttpExceptionFilter` with consistent API error responses\n- 🗣️ `Accept-Language` header support via a `LanguageInterceptor`\n- 🗃️ `RequestContext` for per-request language scoping\n- 🔐 Google OAuth login flow\n- 📚 Clean and extensible `TranslationService` using i18next core\n- 🚀 Designed to be lightweight and free of unnecessary dependencies (no `nestjs-i18n` package required)\n\n---\n\n## Motivation\n\nMost i18n NestJS examples rely on [`nestjs-i18n`](https://github.com/toonvanstrijp/nestjs-i18n), which is great but often overkill for APIs.\nThis starter project demonstrates a lightweight, fully controlled way to integrate:\n\n- i18next directly\n- Validation with dynamic placeholders (e.g., `{{max}}`, `{{min}}`, `{{length}}`)\n- Clean API response patterns\n- Authentication via Google OAuth\n\n---\n\n## Architecture Highlights\n\n- ✅ **TranslationService** — wraps and initializes `i18next`\n- ✅ **I18nextValidationPipe** — extends `ValidationPipe`, adds automatic arg completion for common constraints (`minLength`, `maxLength`, `equals`, `length`, etc.)\n- ✅ **HttpExceptionFilter** — consistent error responses with proper translation\n- ✅ **LanguageInterceptor** — populates `RequestContext.lang` based on `Accept-Language` header\n- ✅ **Validation messages** — stored in `i18n/{{lng}}/validation.json`\n- ✅ **Google OAuth** — integrated as a flexible auth provider\n\n---\n\n## Folder structure\n\n```\nsrc/\n├── common/\n│   ├── context/              → RequestContext\n│   ├── exceptions/           → I18nValidationException\n│   ├── filters/              → HttpExceptionFilter\n│   ├── interceptors/         → LanguageInterceptor\n│   ├── pipes/                → I18nextValidationPipe\n│   ├── services/             → TranslationService\n│   └── helpers/              → Utility helpers (BaseResponse, etc.)\n├── enums/                    → Translation groups, API error codes\n├── i18n/                     → Translations (validation.json, messages.json)\n└── auth/                     → Google OAuth flow, DTOs, controllers\n```\n\n---\n\n## Usage\n\n### Validation example (LoginDto)\n\n```typescript\n@MaxLength(10)\n@MinLength(6)\n@IsNotEmpty()\n@IsEmail()\n```\n\n- No need to pass `{ max }` or `{ min }` — handled automatically by `I18nextValidationPipe`.\n- Validation messages pulled from `validation.json`.\n\n---\n\n### Example Validation Message\n\n```json\n{\n  \"fieldErrors\": [\n    {\n      \"field\": \"password\",\n      \"message\": \"Must be at most 10 characters.\"\n    }\n  ]\n}\n```\n\n---\n\n## Why not use `nestjs-i18n`?\n\n- Full control of `i18next` integration\n- No additional package dependency\n- Easier to fine-tune behavior for API-specific needs\n- Works seamlessly with `ValidationPipe` and `HttpExceptionFilter`\n\n---\n\n## Roadmap\n\n- ✅ i18n with i18next\n- ✅ ValidationPipe auto-args\n- ✅ BaseResponse + consistent API error contract\n- ✅ Google OAuth login flow\n- ✅ Ready for production use\n\n🔧 Possible future improvements:\n\n- i18n caching\n- Multi-namespace support with dynamic loading\n- Support for more advanced i18next plugins\n\n---\n\n## Getting Started\n\n```bash\ngit clone https://github.com/iibalena/nestjs-api-i18n-auth-starter.git\ncd nestjs-api-i18n-auth-starter\nnpm install\nnpm run start:dev\n```\n\n---\n\n## License\n\nMIT\n\n---\n\n## Contributing\n\nFeel free to fork, star, and contribute via PRs!\nFeedback and ideas are always welcome.\n\n---\n\n## Author\n\nDeveloped by [Ivonei Balena](https://github.com/iibalena) with ❤️\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiibalena%2Fnestjs-api-i18n-auth-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiibalena%2Fnestjs-api-i18n-auth-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiibalena%2Fnestjs-api-i18n-auth-starter/lists"}