
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
decorative-model
Advanced tools
This is a helper lib for coding the logic of dto and data model with oop style
When handle transfer data between client and server, we always need to transform the data, it mostly is boring and repetitive work:
JSON.parse and JSON.stringify to transform the data between JSON String and JS Plain Object, fortunately, this work was done by other libraries (axios, fetch, etc.)And there are some common cases we are facing:
For dealing with these cases, we have to do some extra and repetitive work, and mostly, it is not easy to maintain and is ugly-prone.
Decorator is a good way to solve these problems, it can help us to do some extra work when we declare a class or a property, and it is easy to maintain and extend. By using decorator and class, we can code with OOP style, and it is more readable and maintainable.
class-transformer is a good library to help us to deal with these works, it provides some decorators and methods to help us to transform the data between client and server, so we no more need to do these works manually and focus on the business logic. And for much easier to use, this library further box the class-transformer, and provide a simple API to use. not only that, this library also provide validate feature, it can help us to validate the data before we send it to server.
emitDecoratorMetadata;For mostly cases, refer to ./model/User.ts
decorator feature, you should enable experimentalDecorators and emitDecoratorMetadata in your tsconfig.jsonemitDecoratorMetadata is required for @Field decorator, it helpers to get the type of the field, but it relies on compiler, unfortunately, it's not supported in esbuild yet. tsc and swc are recommended. We also provide a vite plugin to help you do this.import emitDecoratorMetadata from 'decorative-model/vite-plugin/emit-decorator-metadata'
// esbuild does not support emitDecoratorMetadata
export default defineConfig({
/** ... */
plugins: [
emitDecoratorMetadata({ include: [/.ts$/], tsconfig: 'tsconfig.json' }),
],
/** ... */
})
import { NamingCase, setDefaultClassNamingCase, setDefaultPlainNamingCase } from 'decorative-model'
// NamingCase.snake_case
// NamingCase.camelCase
// NamingCase.PascalCase
// NamingCase.NonCase
// when you are using snake-case in client side
setDefaultClassNamingCase(NamingCase.snake_case)
// when you are using camel-case in server side
setDefaultPlainNamingCase(NamingCase.camelCase)
// when your client side and server side is using the same naming-case standard,
// you should just do this, and declare fields in class whatever.
setDefaultClassNamingCase(NamingCase.NonCase)
setDefaultPlainNamingCase(NamingCase.NonCase)
FAQs
This is a helper lib for coding the logic of dto and data model with oop style
The npm package decorative-model receives a total of 2 weekly downloads. As such, decorative-model popularity was classified as not popular.
We found that decorative-model 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.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.