{"id":25451083,"url":"https://github.com/devnet-io/creditcard-validator","last_synced_at":"2025-05-16T09:37:48.829Z","repository":{"id":277374729,"uuid":"932223310","full_name":"devnet-io/creditcard-validator","owner":"devnet-io","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-13T15:30:58.000Z","size":86,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T16:37:19.656Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/devnet-io.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}},"created_at":"2025-02-13T15:14:35.000Z","updated_at":"2025-02-13T15:31:02.000Z","dependencies_parsed_at":"2025-02-15T23:45:25.610Z","dependency_job_id":null,"html_url":"https://github.com/devnet-io/creditcard-validator","commit_stats":null,"previous_names":["devnet-io/creditcard-validator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnet-io%2Fcreditcard-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnet-io%2Fcreditcard-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnet-io%2Fcreditcard-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnet-io%2Fcreditcard-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devnet-io","download_url":"https://codeload.github.com/devnet-io/creditcard-validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239373159,"owners_count":19627784,"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-02-17T22:17:22.050Z","updated_at":"2025-02-17T22:17:22.402Z","avatar_url":"https://github.com/devnet-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# creditcard-validator\n\n\n## Demo\nTry the validator out now!\n1. **Visit the demo site: https://d2smo6zr9j53ei.cloudfront.net**\n2. Start typing a credit card number\n\n\u003cimg src=\"https://github.com/user-attachments/assets/d144c902-7cd8-40df-98f4-2556d6b850d5\" width=\"70%\" /\u003e\n\n\n\nOr try calling the backend directly:\n```bash\ncurl 'https://4zi58jxkw7.execute-api.us-east-1.amazonaws.com/api/validateCreditCard' -X POST -H 'Content-Type: application/json' -s --data-raw '{\"number\":\"6011000990139424\",\"expirationDate\":\"12/29\",\"cvc\":\"000\"}'\n```\nExample result:\n```json\n{\n  \"isValid\": true,\n  \"details\": [\n    {\n      \"label\": \"American Express\",\n      \"isValid\": false,\n      \"errors\": [\n        \"Invalid card number length\",\n        \"Invalid card number prefix\"\n      ]\n    },\n    {\n      \"label\": \"Diners Club\",\n      \"isValid\": false,\n      \"errors\": [\n        \"Invalid card number length\",\n        \"Invalid card number prefix\"\n      ]\n    },\n    {\n      \"label\": \"Discover\",\n      \"isValid\": true,\n      \"errors\": []\n    },\n    {\n      \"label\": \"MasterCard\",\n      \"isValid\": false,\n      \"errors\": [\n        \"Invalid card number prefix\"\n      ]\n    },\n    {\n      \"label\": \"Visa\",\n      \"isValid\": false,\n      \"errors\": [\n        \"Invalid card number prefix\"\n      ]\n    }\n  ]\n}\n\n```\n\n\n## Structure\nThe project is divided into three folders / apps:\n\n* backend\n    * **Purpose**: hosts REST API with credit card validator endpoint\n    * **Tech**: Node + Express app, run via AWS Lambda\n* frontend\n    * **Purpose**: hosts UI to demo validation service\n    * **Tech**: React app, run via AWS Cloudfront + S3\n* infra\n    * Terraform IAC to deploy both apps\n    \n\n### Points of Interest\n* [rules.ts](https://github.com/devnet-io/creditcard-validator/blob/main/backend/src/validation/rules.ts) - Defines rules for validating different types of credit cards\n* [cardValidator.ts](https://github.com/devnet-io/creditcard-validator/blob/main/backend/src/validation/cardValidator.ts) - Logic to apply the validation rules to the card details\n\n\n## Deployment\nThis project is intended to be deployed to AWS.\n\nDeployment instructions:\n1. Install [Terraform](https://developer.hashicorp.com/terraform/install?product_intent=terraform) and the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)\n2. Go through the authentication flow for the AWS CLI. Ensure the user/session has the necessary permissions.\n   * Example permissions needed (illustrative only, this is insecure):\n    ![image](https://github.com/user-attachments/assets/f967c218-2a5f-4624-b2b2-fe189f5490a5)\n\n3. Run ```bash up.sh```\n\n\nThat's it! Terraform will take care of creating the resources and will output URLs for the backend and frontend projects when its finished:\n\n## Testing\nRun the tests via jest:\n```bash\ncd backend\nnpm install\nnpm run tests\n```\n\nExample results:\n![image](https://github.com/user-attachments/assets/df2a13e1-ed97-441b-8f92-28cec9e6b75e)\n\n\n## Unfinished Business\n* Input validation for APIs\n* Error handling for APIs\n* More reasonable unit test coverage (single \"integration\" test exists)\n* Refine frontend components, seperate into presentational components and logic ones\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevnet-io%2Fcreditcard-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevnet-io%2Fcreditcard-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevnet-io%2Fcreditcard-validator/lists"}