Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@janiscommerce/api-save
Advanced tools
A package to handle JANIS Views Save APIs
npm install @janiscommerce/api-save
'use strict';
const { ApiSaveData } = require('@janiscommerce/api-save');
const { struct } = require('superstruct');
const MyRelatedModel = require('../../models/my-related-model');
class MyApiSaveData extends ApiSaveData {
static get relationshipsParameters() {
return {
children: {
ModelClass: MyRelatedModel,
mainIdentifierField: 'dbFieldForMainEntity',
secondaryIdentifierField: 'dbFieldForRelatedEntity',
shouldClean: false
}
};
}
static get idStruct() {
return struct.optional('string|number');
}
static get mainStruct() {
return struct.partial({
name: 'string',
description: 'string?',
status: 'number'
});
}
static get relationshipsStruct() {
return struct.partial({
children: ['string']
});
}
format({ someField, ...restoOfTheRecord }) {
return {
...restoOfTheRecord,
someField: `prefix-${someField}`
};
}
}
module.exports = MyApiSaveData;
The following getters and methods can be used to customize and validate your Save API.
All of them are optional, however you're encouraged to implement static get mainStruct()
so you don't save trash data in your DB.
You need to use this in case you're saving relationships with other models (mostly for relational databases) If you don't have any relationship, there's no need to implement it.
This getter must return an object mapping the name of the field that contains the relationship (must be a key in the struct's relationships
property) to the parameters of that relationship.
The parameters contain the following properties:
false
This is used to validate the ID received as path parameter. Defaults to an optional string or number.
This is used to validate the data received in the request, checking the data to be saved in the main entity. Defaults to an object with any property.
This is used to validate the data received in the request, checking the data to be passed to the relationships. Defaults to an object partial with no properties.
You can use this to format your main record before it's saved. For example, mapping user friendly values to DB friendly values, add default values, etc.
[3.0.1] - 2019-08-06
FAQs
A package to handle Janis Save APIs
The npm package @janiscommerce/api-save receives a total of 251 weekly downloads. As such, @janiscommerce/api-save popularity was classified as not popular.
We found that @janiscommerce/api-save 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.