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

@grp-toska/apina

v0.0.1

Published

Intended to remove some api boilerplate

Readme

DIY boilerplate remover

Consists of 4 parts:

getMiddleware

getMiddleware is a function that will create a middleware. It takes one parameter which is an object passed to axios as default values. See https://github.com/axios/axios#request-config for request config.

Usage:

import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'

import { middleware as simpleApi } from '@toska/apina'
import combinedReducers from './redux'

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

const store = createStore(
  combinedReducers,
  composeEnhancers(applyMiddleware(thunk, simpleApi({ baseURL: '/api' }))),

apiReducer and errorReducer

You can write your own reducers, but apiReducer will work for a restful api (?). It's written with convention over configuration in mind so if you want anything different I suggest writing your own.

ErrorReducer is also optional and will offer all request errors so you can push changes to a toast or notification.

Usage:

import { combineReducers } from 'redux'

import { apiReducer as api } from '@toska/apina'
import { errorReducer as errors } from '@toska/apina'

export default combineReducers({
  api,
  errors
})

buildAction

buildAction will return an action for you to dispatch. You can await the dispatch at it will return the data (or error), the promise is resolved with the request.

Usage:

import { buildAction } from '@toska/apina'

/**
 * The first parameter will be the resource in redux store
 */

export const getMessagesAction = () =>
  buildAction('messages', { url: '/messages' })

/**
 * Second parameter accepts anything axios would accept
 */
export const postMessageAction = (message) =>
  buildAction('messages', { url: '/messages', method: 'post', data: message })

/**
 * Since a DELETE request will only receive a 200 OK message we need to pass the id as the 3rd parameter.
 */
export const deleteMessageAction = (id) =>
  buildAction('messages', { url: `/messages/${id}`, method: 'delete' }, id)

Convention

Your API should return objects with id field. If they do not have an id field or if the response is not an object (or in case of GET /collection requests, an array) the middleware and/or reducer will not work.