Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@master/business
Advanced tools
```tree . ├── businesses │ └── member │ ├── member.controller.ts │ ├── member.service.ts │ ├── member.ts // DAO │ └── signing-up.ts └── shared ```
.
├── businesses
│ └── member
│ ├── member.controller.ts
│ ├── member.service.ts
│ ├── member.ts // DAO
│ └── signing-up.ts
└── shared
npm install @master/business
tsconfig.json
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
}
extends BusinessModel
命名規則:Ving + N
@Business
裝飾模型
@Input(options?)
裝飾需驗證格式的欄位
options | type | description |
---|---|---|
disabled | boolean | 用於禁用 extends 對象的同樣 @Input() 屬性 |
required | boolean | 必輸入 |
arrayType | any | 類型為 SomeType[] 必須於此額外定義目標類型 |
enum | Record<string, any> | 類型為 enum 須於此額外定義目標類型 |
@Output(options?)
裝飾需輸出的欄位
options | type | description |
---|---|---|
disabled | boolean | 用於禁用 extends 對象的同樣 @Input() 屬性 |
前端藉由 sign-up API 將註冊資料輸入至 Server,Server 再將註冊結果輸出回前端
// signing-up.ts
import { Business, BusinessModel, Input } from '@master/business';
@Business()
export class SigningUp extends BusinessModel {
@Output()
// 輸入:姓名為字串且必填
@Input({ required: true })
name: string;
// 輸入:地址,根據巢狀類型驗證欄位
@Output()
@Input()
address: SigningUpAddress;
// 其他業務過程的產物欄位
a = 1;
b = 2;
}
@Business()
class SigningUpAddress extends BusinessModel {
@Output()
@Input()
city: string;
@Input()
district: string;
@Input()
street: string;
}
// member.controller.ts
import { Business, BusinessModel, Input, validate } from '@master/business';
import { Controller, Post, Res, Body } from '@nestjs/common';
import { MemberService } from './member.service.ts';
import { SigningUp } from './signing-up.ts';
@Controller('member')
export class MemberController {
constructor(
private memberService: MemberService
) {}
@Post()
async SignUp(
@Body() data: any,
@Res() res: Response
): Promise<void> {
const signingUp = new SigningUp(data);
const errors = signingUp.validate();
// 驗證
if(errors.length) {
// 欄位錯誤
res.status(400).send(errors);
} else {
// 欄位正確
// 註冊相關業務邏輯 ...
this.memberService.signUp(signingUp);
res.status(200).send(signingUp);
}
}
}
{
name: "joy",
address: {
city: "taipei",
district: "zhongshan",
street: "my home"
}
}
{
name: "joy",
address: {
city: "taipei",
district: "zhongshan",
street: "my home"
},
a: 1,
b: 2
}
{
name: "joy",
address: {
city: "taipei"
}
}
@Business()
class MyBusiness extends BusinessModel {
@Input()
str: string;
@Input()
num: number;
@Input({ enum: MyEnum })
enum: MyEnum;
@Input({ arrayType: MyArrayType })
arrayType: MyArrayType[];
}
FAQs
A business data model for quick verification, access and output of specific data formats.
The npm package @master/business receives a total of 0 weekly downloads. As such, @master/business popularity was classified as not popular.
We found that @master/business demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.