Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@vtex/api
Advanced tools
This library enables developers to quickly integrate with the VTEX IO APIs and create full fledged node services using VTEX IO.
For a complete example on using @vtex/api
, check out this app: https://github.com/vtex-apps/service-example
The most basic usage is to export a new Service()
with your route handlers:
// Import global types
import './globals'
import { Service } from '@vtex/api'
import { clients } from './clients'
import example from './handlers/example'
// Export a service that defines route handlers and client options.
export default new Service({
clients,
routes: {
example,
},
})
This allows you to define middlewares that receive a Context
param which contains all IO Clients in the clients
property:
export const example = async (ctx: Context, next: () => Promise<void>) => {
const {state: {code}, clients: {apps}} = ctx
console.log('Received code:', code)
const apps = await apps.listApps()
ctx.status = 200
ctx.body = apps
ctx.set('Cache-Control', 'private')
await next()
}
ctx.clients.apps
is an instance of Apps
.
yarn
yarn watch
yarn
yarn link
yarn watch
cd ../<your-app>/node
yarn link @vtex/api
Now, when you get a workspace up and running for your app with vtex link
, you'll have this package linked as well.
When done developing, don't forget to unlink it from
<your-app>/node
:yarn unlink @vtex/api
[6.45.15] - 2023-02-01
FAQs
VTEX I/O API client
The npm package @vtex/api receives a total of 5,223 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.