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

retoolrpc

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retoolrpc

TypeScript package for Retool RPC

  • 0.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6K
increased by21.47%
Maintainers
1
Weekly downloads
 
Created
Source

retoolrpc JavaScript client package

Review Retool's RPC documentation before installing the JavaScript package.

Installation

You can use npm, yarn, or pnpm to install the package.

npm

# Using npm
npm install retoolrpc

# Using yarn
yarn add retoolrpc

# Using pnpm
pnpm add retoolrpc

Usage example

import { RetoolRPC } from 'retoolrpc'
// for CommonJS, uses `require`, e.g.:
// var { RetoolRPC} = require('retoolrpc')

const rpc = new RetoolRPC({
  apiToken: 'your-api-token-here', // Replace this token with your API token
  host: 'http://localhost:3000/', // Replace this host with your host
  resourceId: 'resource-id', // Replace this resource ID with your ID
  environmentName: 'production', // Replace this environment name with your name (defaults to production)
  pollingIntervalMs: 1000, // The polling interval for the RPC
  pollingTimeoutMs: 5000, // The polling timeout for the RPC
  version: '0.0.1', // An optional version number for functions schemas
  logLevel: 'info', // Change to 'debug' for verbose logging or use own logger implementation by passing a logger param
})

rpc.register({
  name: 'helloWorld',
  arguments: {
    name: { type: 'string', description: 'Your name', required: true },
  },
  implementation: async (args, context) => {
    return {
      message: `Hello ${args.name}!`,
      context,
    }
  },
})

await rpc.listen()

ORM Support

For users of Sequelize, we offer an ORM mixin that enables the addition of fundamental model functions with a single function call, registerModel. When you register a model with rpc, it automatically registers various remote functions for the model, including create, update, createOrUpdate, findByPk, findBy, and findAll. You can find additional details here.

Following is an example of registering a User model:

import { RetoolRPC, sequelizeMixin } from 'retoolrpc'
import { User } from './orm/models' // the path to your model may be different

const CustomRPC = sequelizeMixin(RetoolRPC)
const rpc = new CustomRPC({ ... })

rpc.registerModel({
  model: Experiment,
  findByAttributes: ['id', 'name'],
  writeAttributes: ['name'],
})

We plan to support other ORMs in the future.

FAQs

Package last updated on 19 Mar 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