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

@kanda-libs/ks-frontend-services

v0.3.49

Published

Downloads

485

Readme

ks-frontend-services

This repo takes the schema.yaml defined in ks-schema (one directory up) and transforms it into a number of different functions & variables that are used on the frontend in kanda for fetching and manipulating from the API. It exposes:

  1. A services object -> This services object is a map of possible entities (company, job, payment etc) to each entities respective API calls such as services.company.getCompany. These API functions use fp-ts to handle any potential errors and need to be run through handleResponse in order to correctly handle a given API call
  2. useLoadData / useSubmit react hooks for calling the API via the services object -> Both hooks use useSWR and fp-ts under the hood to handle calling the API and error reportng. useLoadData is used for API GET calls, and returns data, error & isValidating from the hook. Example:
const { data: jobs, isValidating, error } = useLoadData(services.job.getJobs);

// data is type `Job[]`

useSubmit is then used for all other API calls, such as PUT or POST and takes the relevant params to be sent with the API call. For example:

  const { submit: completeJob, isSubmitting } = useSubmit(
    services.job.completeJob,
  );

  //...

  completeJob({ params: { id: job.id || '' } }).then(({ data, error }) => {
      // API call has either passed or failed
  });
  1. Code-gen'd redux store: See Redux documentation
  2. Middleware: Middleware for handling routing, authentication checking and initial data loading on the frontend. See: Middleware documentation

Checking schema changes locally

There may be times when you need to use a local version of ks-frontend-services in another locally hosted application. To do this you'll need to take the following steps:

  1. Navigate one directory up to ks-schema and run make clean build -> This runs code gen for the services object etc. Any new entities will now be available
  2. Build ks-frontend-services and publish to yalc: cd ks-frontend-services && yarn build && yalc publish
  3. Use the new yalc package in your local application (for instance ks-dashboard-frontend): Navigate to your project and run yalc add --link @kanda-libs/ks-frontend-services. You may have to restart your application to see any relevant changes

Please note: Yalc will make changes to your package.json to point to your new local instance of ks-frontend-services. It's important this isn't committed to your branch as pushing this to QA/Production etc will break the build of that given application