{"id":25488374,"url":"https://github.com/master-co/business","last_synced_at":"2025-11-08T06:30:35.259Z","repository":{"id":109344132,"uuid":"337329807","full_name":"master-co/business","owner":"master-co","description":"A business data model for quick verification, access and output of specific data formats.","archived":false,"fork":false,"pushed_at":"2022-02-09T11:04:12.000Z","size":340,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T00:59:16.838Z","etag":null,"topics":["angular","api","bo","data-format","data-model","dto","express","input","inputs","koa","nestjs","nodejs","output","react","request","response","typescript","verification","vue"],"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/master-co.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}},"created_at":"2021-02-09T07:49:06.000Z","updated_at":"2024-04-17T06:28:14.877Z","dependencies_parsed_at":null,"dependency_job_id":"ff674fc7-87ba-463e-9583-b8e37fbc08ce","html_url":"https://github.com/master-co/business","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.375,"last_synced_commit":"31ad1bda75d307390905a58bfbb9faba2a6de9cc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/master-co%2Fbusiness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/master-co%2Fbusiness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/master-co%2Fbusiness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/master-co%2Fbusiness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/master-co","download_url":"https://codeload.github.com/master-co/business/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239494665,"owners_count":19648175,"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":["angular","api","bo","data-format","data-model","dto","express","input","inputs","koa","nestjs","nodejs","output","react","request","response","typescript","verification","vue"],"created_at":"2025-02-18T20:51:41.486Z","updated_at":"2025-11-08T06:30:35.217Z","avatar_url":"https://github.com/master-co.png","language":"TypeScript","readme":"\n\u003ca href=\"#\" target=\"_blank\"\u003e\n    \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" /\u003e\n\u003c/a\u003e\n\n# Master Business\n### A business data model for quick verification, access and output of specific data formats.\n\n\u0026nbsp;\n\n```shell\nnpm install @master/business\n```\n\n### `tsconfig.json`\n```tsx\n{\n    \"compilerOptions\": {\n        \"emitDecoratorMetadata\": true,\n        \"experimentalDecorators\": true\n    }\n}\n```\n\n## Usage\n\n```tsx\nimport { Business, BusinessModel, Input, Output } from '@master/business';\n\n@Business()\nexport class MyBusiness extends BusinessModel {\n    @Input()\n    prop1: string;\n\n    @Output()\n    prop2: number;\n\n    @Input()\n    @Output()\n    prop3: OtherBusinessModel;\n\n    ...\n}\n\n```\n\n### `@Input(options?)`\nDecorate the property that need to be validated\n\n| options     | type                | description                                                                        |\n| ----------- | ------------------- | ---------------------------------------------------------------------------------- |\n| `disabled`  | boolean             | Used to disable the @Input() decoration behavior of extended objects               |\n| `required`  | boolean             | Is the property required                                                           |\n| `arrayType` | any                 | Assuming the type is YourType[], the target type must be additionally defined here |\n| `enum`      | Record\u003cstring, any\u003e | Assuming the type is enum, the target type must be additionally defined here       |\n\n### `@Output(options?)`\nDecorate the property that need to be outputed\n\n| options    | type    | description                                                          |\n| ---------- | ------- | -------------------------------------------------------------------- |\n| `disabled` | boolean | Used to disable the @Input() decoration behavior of extended objects |\n\n## Example\nThe front-end inputs the registration data to the server through the sign-up API, and then outputs the registration result back to the front-end.\n\n### File Structure\n```tree\n├── businesses\n│   └── member\n│       ├── member.controller.ts\n│       ├── member.service.ts\n│       ├── member.ts // DAO\n│       └── signing-up.ts\n```\n\n### Define the business model\n```tsx\n// signing-up.ts \n\nimport { Business, BusinessModel, Input } from '@master/business';\n\n@Business()\nexport class SigningUp extends BusinessModel {\n\n    @Output()\n    @Input({ required: true })\n    name: string;\n\n    @Output()\n    @Input()\n    address: SigningUpAddress;\n\n    @Output()\n    type = 'general';\n\n    // other fields for quick access\n    a = 1;\n    b = 2;\n    c = 3;\n    d = 4;\n}\n\n@Business()\nclass SigningUpAddress extends BusinessModel {\n    \n    @Output()\n    @Input()\n    city: string;\n\n    @Input()\n    district: string;\n    \n    @Input()\n    street: string;\n}\n```\n\n### Process business logic ( nestjs for example )\n```tsx\n// member.controller.ts\n\nimport { Business, BusinessModel, Input, validate } from '@master/business';\nimport { MemberService } from './member.service.ts';\nimport { SigningUp } from './signing-up.ts';\n\n@Controller('member')\nexport class MemberController {\n        constructor(\n        private memberService: MemberService\n    ) {}\n\n    @Post()\n    async SignUp(\n        @Body() data: any,\n        @Res() res: Response\n    ): Promise\u003cvoid\u003e {\n\n        const signingUp = new SigningUp(data);\n        const errors = signingUp.validate();\n\n        // validate\n        if(errors.length) {\n            // property error\n            res.status(400).send(errors);\n        } else {\n            // correct\n            // business logic process here ...\n            this.memberService.signUp(signingUp);\n            res.status(200).send(signingUp);\n        }\n    }\n}\n```\n\n### *Input*：request data\n```tsx\n{\n    name: \"joy\",\n    address: {\n        city: \"taipei\",\n        district: \"zhongshan\",\n        street: \"my home\"\n    }\n}\n```\n\n### *Processing*：business data\n```tsx\n{\n    name: \"joy\",\n    address: {\n        city: \"taipei\",\n        district: \"zhongshan\",\n        street: \"my home\"\n    },\n    type: 'general',\n    a: 1,\n    b: 2,\n    c: 3,\n    d: 4\n}\n```\n\n### *Output*：response data\n```tsx\n{\n    name: \"joy\",\n    address: {\n        city: \"taipei\"\n    },\n    type: 'general'\n}\n```\n\n## @Input definitions\n```tsx\n@Business()\nclass MyBusiness extends BusinessModel {\n    @Input()\n    str: string;\n\n    @Input()\n    num: number;\n\n    @Input({ enum: MyEnum })\n    enum: MyEnum;\n\n    @Input({ arrayType: MyArrayType })\n    arrayType: MyArrayType[];\n}\n```\n\n## Solutions\n- ### Provide a rich access interface for developers\n- ### Follow the DRY principle (Don't repeat yourself)\n- ### Omit the definition of Request DTO and Response DTO data structure\n- ### Data structure focuses on one interface\n- ### Reduce code writing\n- ### No need to define variables individually to manipulate data\n\n## Code Contributors\n|[\u003cimg alt=\"BenSeage\" src=\"https://avatars.githubusercontent.com/u/37956868?v=4\u0026s=117\" width=\"117\"\u003e](https://github.com/BenSeage) |[\u003cimg alt=\"aron-tw\" src=\"https://avatars.githubusercontent.com/u/33840671?v=4\u0026s=117\" width=\"117\"\u003e](https://github.com/aron-tw) |[\u003cimg alt=\"miles0930\" src=\"https://avatars.githubusercontent.com/u/8224584?v=4\u0026s=117\" width=\"117\"\u003e](https://github.com/miles0930)  |[\u003cimg alt=\"BenSeage\" src=\"https://avatars.githubusercontent.com/u/8954023?v=4\u0026s=117\" width=\"117\"\u003e](https://github.com/zxa011023) |\n:---:|:---:|:---:|:---:|\n[BenSeage](https://github.com/BenSeage)|[Aron](https://github.com/aron-tw)|[Miles](https://github.com/miles0930)|[Lola](https://github.com/zxa011023)|\n|creator|designer|maintainer|maintainer\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaster-co%2Fbusiness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaster-co%2Fbusiness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaster-co%2Fbusiness/lists"}