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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@horos/resi-client

v0.2.9

Published

Resi Web API Client Package

Downloads

3

Readme

Resi Web API Platform

This is still in testing

This platform allows you to implement your API on the server side, and generate a client side with built in intellisense support.

The package ships with PASETO token management, and support for streaming responses from the server.

This is the CLIENT version. For server, refer to @horos/resi-server.

Installation

npm i -s @horos/resi-client or yarn add @horos/resi-client

Server side usage

  1. Create 2 folders, one for your api files (the actual functions) and one for your models.
  2. Create a model file
export class TestModel {
  /**
   *
   * @param {string} a
   */
  constructor(a) {
    this.a = a;
  }
}
  1. Create an API file
import { TestModel } from '../models/testModel';
import { enrich, authorization } from '@horos/resi-server/plugs';
import { createAPIImplementation } from '@horos/resi-server/create-api';

//                                       ⬇ API name
export default createAPIImplementation('test', {
  /**
   * This JSDoc will be kept for intellisense on the client side
   *
   * @param {number} num1
   * @param {number} num2
   * @param {import('@horos/resi-server/dist/create-server').ResiContext} context
   * @returns {Promise<number>}
   */
  test(num1, num2, context) {
    return num1 + num2;
  },

  /**
   * @returns {Promise<import('../models/testModel').TestModel>}
   */

  //         ⬇ Use the enrich function to plug features to your funtion
  shogi: enrich(async function (context) {
    return new TestModel('banana');
    // ⬇ In this case authorization is plugged, which means only authorized clients can invoke this handler
  }, authorization),
});

** New in 0.2.0 **

It is now possible to plug functions with decorators.

export default createAPIImplementation(
  'test',
  // ⬇ To use decorators, you must use a class and not an object literal
  class {
    /**
     *
     * @param {string} searchTerm
     * @param {boolean} onlyCountrySpecific
     * @param {import('@horos/resi-server/dist/create-server').ResiContext} context
     * @returns {Promise<{languages: Language[]}>}
     */
    // ⬇ Use a plug as a decorator instead of using the "enrich" function
    @httpDelete
    searchLanguages(searchTerm, onlyCountrySpecific, context) {
      return `${searchTerm} ${onlyCountrySpecific} 3`;
    }
  },
);
  1. Security object is needed for authorizing incoming requests. 3 Keys are required in total - Public/Private key pair, and a secret key.

You can generate them like this by adding this command to your package.json scripts:

"generate-security-keys": "create-key-set ./security-keys"

  1. Finally create your RESI API using your API and models directories, and your security files.
  • In production, remember to specify the allowed origins for the CORS headers.
  • By default, building the full API is not allowed. When building on the client, make sure to specify APIs, or disable this restriction (see example below).
import { createServerFromResiDir } from '@horos/resi-server';

const securityPaths = {
  publicKey: './security-keys/public',
  privateKey: './security-keys/private',
  secret: './security-keys/secret',
};

async function init() {
  await createServerFromResiDir(
    path.resolve('./src/resi-server/models'),
    path.resolve('./src/resi-server/apis'),
    'dist',
    {
      securityPaths,
      allowedOrigins: ['www.mydomain.com', 'undefined'], // include undefined to support clients who don't rely on cors (i.e. apps). You can also specify a string (i.e. '*' or 'www.mydomain.com')
      allowBuildingFullAPI: false, // using this, a developer wishing to download the API specs is required to specify APIs for download. Use this hide APIs from clients who arent going to use them
      port: 9876,
    },
  );
}

Client side usage

  1. Install @horos/resi-client on your client as well
  2. Make sure the server is running with NODE_ENV set to "development"
  3. Add a script to your package.json "build-client": "build-client http://localhost:9876 ./src/resi-client" API1 API2 Replace the "http://localhost:9876" with the url of your server, and "src/resi-client" with any path you wish. If you allowed building the entire API, you don't need to specify APIs at the end of the command.
  4. Execute the new script. This should create a local API, identical to the one on your server
  5. Test your client
import { makeResiClient } from './resi-client/apis';

export const resi = makeResiClient('http://localhost');

Type "resi." and you should see intellisense auto compeleting according to your server definition.

Execute any function, and it should invoke its equivalent on the server.