{"id":24437604,"url":"https://github.com/adrielcodeco/customer-demo","last_synced_at":"2025-03-13T23:09:59.409Z","repository":{"id":181860572,"uuid":"666756395","full_name":"adrielcodeco/customer-demo","owner":"adrielcodeco","description":"Customers API demo","archived":false,"fork":false,"pushed_at":"2023-07-17T20:59:02.000Z","size":117,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-01-20T18:17:07.547Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://customers-api-demo.co2lab.info/api","language":"TypeScript","has_issues":false,"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/adrielcodeco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["adrielcodeco"]}},"created_at":"2023-07-15T13:24:16.000Z","updated_at":"2023-07-17T18:09:47.000Z","dependencies_parsed_at":"2023-07-17T22:15:18.398Z","dependency_job_id":null,"html_url":"https://github.com/adrielcodeco/customer-demo","commit_stats":null,"previous_names":["adrielcodeco/customer-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrielcodeco%2Fcustomer-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrielcodeco%2Fcustomer-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrielcodeco%2Fcustomer-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrielcodeco%2Fcustomer-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adrielcodeco","download_url":"https://codeload.github.com/adrielcodeco/customer-demo/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243495497,"owners_count":20299922,"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":[],"created_at":"2025-01-20T18:17:10.564Z","updated_at":"2025-03-13T23:09:59.380Z","avatar_url":"https://github.com/adrielcodeco.png","language":"TypeScript","funding_links":["https://github.com/sponsors/adrielcodeco"],"categories":[],"sub_categories":[],"readme":"# Customers API\n\n[![codecov](https://codecov.io/gh/adrielcodeco/customer-demo/branch/develop/graph/badge.svg?token=rdlj9hy3im)](https://codecov.io/gh/adrielcodeco/customer-demo)\n\nDemo API\n\nThe demo is available at [https://customers-api-demo.co2lab.info/api](https://customers-api-demo.co2lab.info/api)\n\n## Installation\n\n```bash\n$ pnpm i\n```\n\n## Building\n\n```bash\n$ pnpm run build\n```\n\n## Running the app locally\n\nTo run the app locally you will need a redis running on localhost:6379.\n\nYou can run redis on docker with the below command:\n\n```bash\n$ docker compose run -p 6379:6379 -d cache\n```\n\nIf your redis is not running on this host or port you can change the redis host and port\nwithin the .env file setting the keys REDIS_HOST and REDIS_PORT.\n\n```bash\n# development\n$ pnpm run start\n\n# watch mode\n$ pnpm run start:dev\n\n# production mode\n$ pnpm run start:prod\n```\n\n## Running the app on docker\n\n```bash\n$ docker compose run -p 8000:80 --build demo\n```\n\n## Running the tests locally\n\n```bash\n# all tests without coverage\n$ pnpm run test\n\n# tests with coverage\n$ pnpm run test:cov\n```\n\n## Running the tests on docker\n\n```bash\n$ docker compose run --build demo-test\n```\n\n## Using the apis\n\nAfter running the application you can open in browser E.g.:\n\n```txt\nhttp://localhost:8000/api\n```\n\nOn /api the application will show a OpenAPI page.\n\nFor test purpose you will need a access token.\nTo get a access token use the below curl E.g.:\n\n```bash\n$ curl --location 'https://accounts.seguros.vitta.com.br/auth/realms/careers/protocol/openid-connect/token' \\\n    --header 'Content-Type: application/x-www-form-urlencoded' \\\n    --data-urlencode 'grant_type=client_credentials' \\\n    --data-urlencode 'client_id=customers' \\\n    --data-urlencode 'client_secret=453000f7-47a0-4489-bc47-891c742650e2' \\\n    --data-urlencode 'username=adrielcodeco@hotmail.com' \\\n    --data-urlencode 'password=YWRyaWVsY29kZWNvQGhvdG1haWwuY29t' \\\n    --data-urlencode 'scope=openid'\n```\n\nafter obtained the access token you can call the customers API to save a customer with the below curl E.g.:\n\n```bash\n$ curl --location 'http://localhost:8000/customers' \\\n    --header 'Content-Type: application/json' \\\n    --header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICIyTGYtamFReXZmQTNCN3dpVHZ3VkxhMjV1cHhiXzUtQXhZSDhmY3kySHhVIn0.eyJleHAiOjE2ODk0NTEyNzYsImlhdCI6MTY4OTQ1MDk3NiwianRpIjoiNmQ1Y2U3ZjctMDRkNC00ZDQ2LWEzNjktMjc0MzQ3Nzc0ZmQyIiwiaXNzIjoiaHR0cHM6Ly9hY2NvdW50cy5zZWd1cm9zLnZpdHRhLmNvbS5ici9hdXRoL3JlYWxtcy9jYXJlZXJzIiwic3ViIjoiNzk0ZmFkNjktMzkxNy00OThmLThhNjUtMWVjZGU5NjlmMGRiIiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiY3VzdG9tZXJzIiwiYWNyIjoiMSIsInJlc291cmNlX2FjY2VzcyI6eyJjdXN0b21lcnMiOnsicm9sZXMiOlsidXNlciJdfX0sInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgZW1haWwiLCJjbGllbnRJZCI6ImN1c3RvbWVycyIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwiY2xpZW50SG9zdCI6IjEwLjUwLjMuMjAyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoic2VydmljZS1hY2NvdW50LWN1c3RvbWVycyIsImNsaWVudEFkZHJlc3MiOiIxMC41MC4zLjIwMiJ9.buubr50Skm7iAelx7DWKj3JJh5c6_ltjLmpFZusEXXfVvCvMJJemWXAsXW5D7k3Ovii40NrPb_inWlg5ubdYq5brVscv6u7h8lln9GQXkhXJ7U52CEgMrkuGry_te4lseebDVvn290jF6k28iHZGoJDnWsEtCAGScbj4QQp3Gh_Uq5Ft6CPfwzEMMAUg8EP590LDfxsbpbCUOzE9Tb2eMpXzyWshCREvZhS-QRH-wSVRfHgz69HHUEtl0gSJYdtixLCjkZ1zlIVoCBqFb5IddxObDjigXrFcUh1KRmcnvcmFLs7tpuGmj5A4p83PBPeU6g-KLkyCwfh8EQAkjV9YwQ' \\\n    --data '{\n        \"document\": 69050007015,\n        \"name\": \"John Doe\"\n    }'\n```\n\n## Deploy to production\n\nThis project follow the [gitflow concept](https://danielkummer.github.io/git-flow-cheatsheet/) by\nthe convenience of being well known.\n\nFollow the gitflow to send your changes to production.\n\nThe pipelines are automated, the application will be deployed to production if the code are merged to\nthe main branch.\n\nThe automation run a terraform that deploy a AWS App Runner service.\n\n## Teste coverage\n\n[![codecov](https://codecov.io/gh/adrielcodeco/customer-demo/branch/develop/graph/badge.svg?token=rdlj9hy3im)](https://codecov.io/gh/adrielcodeco/customer-demo)\n\n[![codecov](https://codecov.io/gh/adrielcodeco/customer-demo/branch/develop/graphs/sunburst.svg?token=rdlj9hy3im)](https://codecov.io/gh/adrielcodeco/customer-demo)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrielcodeco%2Fcustomer-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadrielcodeco%2Fcustomer-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrielcodeco%2Fcustomer-demo/lists"}