
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
clay-resource
Advanced tools

Resource accessor for ClayDB
$ npm install clay-resource --save
'use strict'
const {fromDriver} = require('clay-resource')
const clayDriverMemory = require('clay-driver-memory')
async function tryExample () {
const driver = clayDriverMemory()
const Product = fromDriver(driver, 'Product')
{
const product01 = await Product.create({name: 'Awesome Box', price: 100})
const {id} = product01
await Product.update(id, {price: 200})
const {meta, entities} = await Product.list({
filter: {price: {$gt: 100}}, // Supported operators: "$gt", "$gte", "$lt", "$lte", "$like", "$in" ...etc
page: {size: 25, number: 1}
})
console.log('Found products:', entities, 'total:', meta.total)
await Product.destroy(id)
}
}
tryExample()
Resources are instances of EventEmitter and fires events. See ResourceEvents to know what you can listen.
'use strict'
const { fromDriver, ResourceEvents } = require('clay-resource')
const clayDriverMemory = require('clay-driver-memory')
// Events fired from resource
const {
ENTITY_CREATE,
ENTITY_CREATE_BULK,
ENTITY_UPDATE,
ENTITY_UPDATE_BULK,
ENTITY_DESTROY,
ENTITY_DESTROY_BULK,
ENTITY_DROP
} = ResourceEvents
async function tryEvents () {
let driver = clayDriverMemory()
let Product = fromDriver(driver, 'Product')
Product.on(ENTITY_CREATE, ({ created }) => { /* ... */ })
Product.on(ENTITY_CREATE_BULK, ({ created }) => { /* ... */ })
Product.on(ENTITY_UPDATE, ({ id, updated }) => { /* ... */ })
Product.on(ENTITY_UPDATE_BULK, ({ ids, updated }) => { /* ... */ })
Product.on(ENTITY_DESTROY, ({ id, destroyed }) => { /* ... */ })
Product.on(ENTITY_DESTROY_BULK, ({ ids, destroyed }) => { /* ... */ })
Product.on(ENTITY_DROP, ({ dropped }) => { /* ... */ })
{
let product01 = await Product.create({ name: 'Awesome Box', price: 100 })
/* ... */
}
}
tryEvents()
To add some custom logic before/after resource handling, use .decorate(methodName, decorator).
'use strict'
const { fromDriver } = require('clay-resource')
const clayDriverMemory = require('clay-driver-memory')
async function tryDecoration () {
let driver = clayDriverMemory()
let Product = fromDriver(driver, 'Product')
// Decorate resource method
Product.decorate('create', (create) => async function decoratedCreate (attributes) {
// Add custom check before create
{
let ok = /^[a-zA-Z\d].$/.test(attributes.name)
if (ok) {
throw new Error('Invalid name!')
}
}
let created = await create(attributes) // Call the original method
// Add custom logging after created
{
let logMsg = '[product] New entity created:' + created.id
console.log(logMsg)
}
return created
})
let created = await Product.create({ name: 'foo' })
/* ... */
}
tryDecoration()
To define custom resource, extends ClayResource class and use .fromDriver() method to create new instance
'use strict'
const {ClayResource} = require('clay-resource')
const clayDriverMemory = require('clay-driver-memory')
// Extends ClayResource class
class UserResource extends ClayResource {
/* ... */
}
void async function () {
const driver = clayDriverMemory()
const userResource = UserResource.fromDriver(driver, 'User')
const user = await userResource.create({name: 'Taka Okunishi'})
/* ... */
}()
This software is released under the Apache-2.0 License.
FAQs
Resource accessor for ClayDB
The npm package clay-resource receives a total of 165 weekly downloads. As such, clay-resource popularity was classified as not popular.
We found that clay-resource demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.