{"id":21561081,"url":"https://github.com/shimisnow/poc-nestjs","last_synced_at":"2026-04-13T14:33:45.444Z","repository":{"id":188317832,"uuid":"639597010","full_name":"shimisnow/poc-nestjs","owner":"shimisnow","description":"Implements an authentication REST API using NestJS. Tests with Jest, Supertest and Testcontainers. CI/CD with GitHub Actions to automate testing and deployment process","archived":false,"fork":false,"pushed_at":"2025-07-26T12:34:13.000Z","size":3095,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T12:58:47.586Z","etag":null,"topics":["docker","github-actions","jest","jwt-authentication","nestjs","nx","supertest","testcontainers","typeorm","webpack"],"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/shimisnow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-11T19:50:03.000Z","updated_at":"2025-07-12T14:58:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f0d2feb-8563-41d1-be78-a633cdf98cbf","html_url":"https://github.com/shimisnow/poc-nestjs","commit_stats":null,"previous_names":["shimisnow/poc-nestjs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shimisnow/poc-nestjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shimisnow%2Fpoc-nestjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shimisnow%2Fpoc-nestjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shimisnow%2Fpoc-nestjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shimisnow%2Fpoc-nestjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shimisnow","download_url":"https://codeload.github.com/shimisnow/poc-nestjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shimisnow%2Fpoc-nestjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31757481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T13:27:56.013Z","status":"ssl_error","status_checked_at":"2026-04-13T13:21:23.512Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["docker","github-actions","jest","jwt-authentication","nestjs","nx","supertest","testcontainers","typeorm","webpack"],"created_at":"2024-11-24T09:18:45.024Z","updated_at":"2026-04-13T14:33:45.436Z","avatar_url":"https://github.com/shimisnow.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![POC NestJS](docs/markdown/images/poc-nestjs-bar//export/poc-nestjs-bar.png)\n\n# Authentication API with NestJS\n\n[![Unit Integration](https://github.com/shimisnow/poc-nestjs/actions/workflows/lint-test.yml/badge.svg)](https://github.com/shimisnow/poc-nestjs/actions/workflows/lint-test.yml)\n[![E2E Test](https://github.com/shimisnow/poc-nestjs/actions/workflows/e2e-test.yml/badge.svg)](https://github.com/shimisnow/poc-nestjs/actions/workflows/e2e-test.yml)\n[![Build and publish Docker Images](https://github.com/shimisnow/poc-nestjs/actions/workflows/deploy.yml/badge.svg)](https://github.com/shimisnow/poc-nestjs/actions/workflows/deploy.yml)\n[![Auth Service Docker image size](https://img.shields.io/docker/image-size/shimisnow/pocnestjs-auth-service/latest?logo=docker\u0026label=Auth%20Service)](https://hub.docker.com/r/shimisnow/pocnestjs-auth-service)\n[![Financial Service Docker image size](https://img.shields.io/docker/image-size/shimisnow/pocnestjs-financial-service/latest?logo=docker\u0026label=Financial%20Service)](https://hub.docker.com/r/shimisnow/pocnestjs-financial-service)\n\n## Project Overview\n\nThis project is a robust authentication REST API built using the NestJS framework. Key features include a modular, testable architecture; comprehensive unit and integration testing with Jest; end-to-end testing using Supertest and Testcontainers for application stack testing; and an integrated CI/CD pipeline with GitHub Actions to automate testing and deployment process.\n\n## Key features\n\n- Shows [how to authenticate, issue and invalidate JWT tokens](docs/markdown//resolved-problems/authentication-flow.md) using Redis cache and without storing tokens in database\n- Shows how to E2E test using [Testcontainers](https://testcontainers.com/) to create isolated environments for testing the entire application flow from the api consumer perspective\n- Shows how to make automated deployment to [Docker Hub](https://hub.docker.com/) using [multi-stage builds](https://docs.docker.com/build/building/multi-stage/) and [Github Actions](https://github.com/features/actions)\n- Shows [how to retrieve the account balance in a financial application](docs/markdown/resolved-problems/account-balance.md).This service exists to apply the authentication in a more real scenario\n\n## Tech Stack\n\n- Code organization: monorepo with [Nx](https://nx.dev/)\n- Backend: [NestJS Framework](https://docs.nestjs.com/), TypeScript, Node.js, REST API\n- Database and cache: PostgreSQL, Redis, [TypeORM](https://typeorm.io/)\n- Security: [JWT](https://jwt.io/)\n- Service-to-service communication with Axios\n- Tests: Unit and integration testing ([Jest](https://jestjs.io/)), E2E Testing ([SuperTest](https://github.com/ladjs/supertest) and [Testcontainers](https://testcontainers.com/)), Code coverage ([IstanbulJS](https://istanbul.js.org/))\n- CI/CD: [GitHub Actions](https://github.com/features/actions), [Docker Hub](https://hub.docker.com/u/shimisnow)\n- Documentation: [OpenAPI/Swagger](https://www.openapis.org/), [Postman](https://www.postman.com/) collections, [Compodoc](https://compodoc.app/), [Mermaid (diagram-as-code)](https://mermaid.js.org/)\n- Others: Docker ([with multi-stage build](https://docs.docker.com/build/building/multi-stage/)), [Husky](https://typicode.github.io/husky/), ESLint, Webpack, [winston](https://github.com/winstonjs/winston)\n\n## General organization\n\nThis project has two individual services:\n\n- Auth Service: implements an authentication process with JWT tokens\n- Financial Service: process and store financial data (used to demonstrate the authentication)\n\n```mermaid\nstateDiagram-v2\ndirection LR\n\nstate \"Auth Consumer\" as auth_consumer_group {\n    state \"API request\" as auth_consumer_api_call\n    [*] --\u003e auth_consumer_api_call\n}\n\nstate \"Financial Consumer\" as financial_consumer_group {\n    state \"API request\" as financial_consumer_api_call\n    [*] --\u003e financial_consumer_api_call\n}\n\nstate \"Services\" as service {\n    state \"Auth Service REST API\" as auth\n    state \"Financial Service REST API\" as financial\n}\n\nauth_consumer_api_call --\u003e auth: login or refresh token\nauth --\u003e auth_consumer_api_call: access token\nfinancial_consumer_api_call --\u003e financial: request + access token\nfinancial --\u003e financial_consumer_api_call: financial data\n\nstate \"Infrastructure\" as storage {\n    state \"Auth Database\" as auth_db\n    state \"Cache\" as cache\n    state \"Financial Database\" as financial_db\n}\n\nauth --\u003e auth_db\nauth --\u003e cache\nfinancial --\u003e cache\nfinancial --\u003e financial_db\n```\n\n## DevOps flow\n\n1. Development: lint, unit and integration tests (Jest), adds a coverage report as github pull request comment\n2. Staging: E2E test (Supertest) using [Testcontainers](https://testcontainers.com/) to replicate external dependencies\n3. Production: build all services, create Docker images, and deploy them to Docker Hub\n\n```mermaid\nstateDiagram-v2\ndirection LR\n\nclassDef dev_style fill:#7f51ce\nclassDef staging_style fill:#e3942a\nclassDef prod_style fill:green\n\nstate \"Development\" as development_stage\n\n[*] --\u003e development_stage\n\nstate \"GitHub Actions • Development\" as github_dev_stage {\n    state \"Lint code\" as lint\n    state \"Unit test\" as unit\n    state \"Integration test\" as integration\n    state \"Coverage report\" as coverage\n    [*] --\u003e lint\n    lint --\u003e unit\n    unit --\u003e integration\n    integration --\u003e coverage\n    coverage --\u003e [*]\n}\ngithub_dev_stage:::dev_style\n\ndevelopment_stage --\u003e github_dev_stage\n\nstate \"Staging\" as staging_stage\n\ngithub_dev_stage --\u003e staging_stage\n\nstate \"GitHub Actions • Staging\" as github_staging_stage {\n    state \"Setup Testcontainers\" as testcontainers\n    state \"e2e Tests\" as e2e_tests\n    [*] --\u003e testcontainers\n    testcontainers --\u003e e2e_tests\n    e2e_tests --\u003e [*]\n}\ngithub_staging_stage:::staging_style\n\nstaging_stage --\u003e github_staging_stage\n\nstate \"Production\" as prod_stage\n\ngithub_staging_stage --\u003e prod_stage\n\nstate \"GitHub Actions • Production\" as github_prod_stage {\n    state \"Build code\" as build_code\n\tstate \"Create Docker images\" as docker_images\n\tstate \"Deploy do DockerHub\" as docker_hub\n\t[*] --\u003e build_code\n\tbuild_code --\u003e docker_images\n\tdocker_images --\u003e docker_hub\n\tdocker_hub --\u003e [*]\n}\ngithub_prod_stage:::prod_style\n\nprod_stage --\u003e github_prod_stage\ngithub_prod_stage --\u003e [*]\n```\n\n## Documentation\n\n- [How to contribute](./CONTRIBUTING.md)\n- [How to run from code](docs/markdown/how-to-run.md)\n- [How to run with Docker](docs/markdown/how-to-deploy.md)\n- [Database structure, TypeORM entities, and migrations](docs/markdown/database-structure.md)\n- [GitHub Actions](docs/markdown/github-actions.md)\n- [Documentation](docs/markdown/documentation.md)\n- [Testing](docs/markdown/testing.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshimisnow%2Fpoc-nestjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshimisnow%2Fpoc-nestjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshimisnow%2Fpoc-nestjs/lists"}