Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@vtex/api
Advanced tools
This client enables Node developers to quickly integrate with the VTEX IO APIs.
Usage:
We generally create a Resources
class that groups all relevant clients and initialize them with the current request's ctx.vtex
context, which includes authToken
, account
, workspace
, etc.
import {Apps, LRUCache, Registry, VBase, ServiceContext} from '@vtex/api'
const MAX_ELEMS = 1000
const RESPONSE_CACHE_TTL_MS = 60 * 60 * 1000
const LONG_TIMEOUT = 20 * 1000
const cacheStorage = new LRUCache<string, any>({
max: MAX_ELEMS,
maxAge: RESPONSE_CACHE_TTL_MS,
})
// `cacheStorage` has a `getStats` method.
metrics.addOnFlushMeter(() => ({...cacheStorage.getStats(), name: 'example-cache-stats'}))
export default class Resources {
public apps: Apps
public registry: Registry
public vbase: VBase
constructor (ctx: ColossusContext) {
const opts = {cacheStorage}
const withLongTimeout = {...opts, timeout: LONG_TIMEOUT}
this.apps = new Apps(ctx.vtex, withLongTimeout)
this.registry = new Registry(ctx.vtex, withLongTimeout)
this.vbase = new VBase(ctx.vtex, opts)
}
}
Install the dependencies (yarn
) and run yarn watch
.
An example usage of the three supported methods of sending a file to VBase:
import {VBase} from '@vtex/api'
import {createReadStream} from 'fs'
const client = new VBase({
account: 'account',
workspace: 'workspace',
authToken: 'test',
userAgent: 'test send',
region: 'aws-us-east-1',
})
client.saveFile(
'bucket',
'test-send-stream-gzip.txt',
createReadStream('./test-send.txt'),
{gzip: true, gzipOptions: {level: 9}}
).then((res) => {
console.log('gz:', res)
})
client.saveFile(
'bucket',
'test-send-stream.txt',
createReadStream('./test-send.txt'),
{gzip: false}
).then((res) => {
console.log('stream:', res)
})
client.saveFile(
'bucket',
'test-send-file.txt',
'./test-send.txt'
).then((res) => {
console.log('file:', res)
})
FAQs
VTEX I/O API client
The npm package @vtex/api receives a total of 5,505 weekly downloads. As such, @vtex/api popularity was classified as popular.
We found that @vtex/api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.