Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vtex/api

Package Overview
Dependencies
Maintainers
0
Versions
890
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vtex/api

VTEX I/O API client

  • 6.48.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

VTEX IO API Client for Node

This library enables developers to quickly integrate with the VTEX IO APIs and create full fledged node services using VTEX IO.

Build Status

Getting started

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.

Development

  • Install the dependencies: yarn
  • Watch for changes: yarn watch

Development with IO clients

  • Install the dependencies: yarn
  • Link this package: yarn link
  • Watch for changes: yarn watch
  • Move to the app that depends on the changes made on this package: cd ../<your-app>/node
  • Link this package to your app's node_modules: 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

Keywords

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc