
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
this is a front end easy model manager
import em2 from 'em2';
const User = new em2({
url: [api],
fields: [model fields, for cleaning params under POST, PUT, OPTIONS... methods]
}, {
pkey: [id => primary key, default is '_id'],
parseData: [function => global parseData handler, when data fetched, just after data to json object],
exception: [function => global error handler],
})
fields can used three way:
fields: {
name: {
type: String,
default: '',
},
age: {
type: Number,
default: 0,
}
...
}
fields: [
{
name,
type: String,
default: '',
},
{
name: 'age',
type: Number,
default: 0
}
...
]
or simple way:
fields: ['name', 'age', ...]
then use it:
//GET api?name=a&sex=b
User.find({name: 'a', sex: 'b'}).then(data => {
// after parseData if have parseData
}).catch(error => {
// after exception if have
})
//GET api/:_id?name=a&sex=b
User.findOne(_id, params).then(succFunc).catch(errFunc)
//POST api body: params
User.create(params)...
//PUT api/:_id body:params
User.update({_id, name: 's', ...})
//POST or PUT, whether params has model's pkey
User.save(params)
//DELETE api?name=a&sex=b
User.destroy({_id, name: 'a',...})
const Comment = new em2({
url: '/post/:post_id/comment'
})
// GET /post/[post_id]/comment
Comment.find({post_id, ...})
// GET /post/[post_id]/comment/[_id]
Comment.findOne({post_id, _id})
// request
User.request(['get', 'post', ...], api, params).then(data => {
// after parseData
}).catch(error => {
// after exception
})
warning:
if you need model's this(like this.pkey, or this.fields), function parseData should not be write in arrow function. neither do function exception
FAQs
es6 easy model manage
The npm package em2 receives a total of 7 weekly downloads. As such, em2 popularity was classified as not popular.
We found that em2 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.