
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.
@palmares/serializers
Advanced tools
This package is responsible for validating incoming requests and format how the requests are sent to the user.
This is used for serializing and deserializing json data. Actually what this will do is mostly validating the data, but it will also be used to do conversion of the data so we guarantee that the data that is being sent and the data that is being received is known.
import {
Serializer,
OutSerializerType,
StringField,
ModelSerializer,
} from '@palmares/serializers';
import { Post, User } from './models';
export class UserSerializer extends ModelSerializer {
fields = {
userPosts: PostSerializer.new({
isDynamicRepresentation: true,
many: true,
}),
};
options = {
model: User,
excludes: ['password'] as const,
};
async save() {
const data = this.validatedData;
const modelInstance = User.default.getInstance<SequelizeEngine<User>>();
if (data) return modelInstance.create(data);
}
}
export class PostSerializer extends ModelSerializer {
options = {
model: Post,
excludes: ['id', 'userUuid'] as const,
};
}
Some nice things that we offer is that we are able to create a schema directly from the models without needing to create anything new. We just pass the models and the fields we want to exclude or include. With that we will automatically detect the types and everything else.
With this you are also able to define isDynamicRepresentation of data. The idea is that by defining isDynamicRepresentation we will be able to
just pass the instance and the framework takes care of retrieving the relation data. It will obviously be less efficient than if you didn't use
this. But it's handy for most use cases.
Also you don't need to create a save method, the framework can take care of this for you.
If you want you can convert this serializer data to your favorite schema library like yup, joi or zod so you can use it in other environments
like on the front-end, or just to gain some improvements in performance.
const serializer = UserSerializer.new();
const schema = await serializer.schema()
many = true)const zodSchema = new ZodSchema();
const schema = await zodSchema.getObject(serializer);
FAQs
This package is responsible for validating incoming requests and format how the requests are sent to the user.
We found that @palmares/serializers 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.