npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

retoolrpc

v0.1.6

Published

TypeScript package for Retool RPC

Downloads

41,770

Readme

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.