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

vue-backend-tools

v1.1.1

Published

Tools to communicate with backend, cache results, store objects

Readme

Vue Backend Tools

Allows to call multiple backends, supports caching.

Features:

  • Cache listings, reusable objects that only have to implement "id" field
  • Multiple backends
  • Custom headers per all backend calls
  • Authorization per backend

Created for wolnosciowiec.org

Example bootstrap

/*
 * Initialize core classes used to interact with backend
 */
const backend = new BackendApi({
  'wolnosciowiec': {
    'url': isDevEnvironment() ? 'http://localhost' : 'https://wolnosciowiec.net',
    'headers': {
      'Authorization': 'some token here'
    },
    'error_handler': function (error, args) { 
      window.console.error('Error!', error, 'Args:', args)
    }
  },

  'news-feed-provider': {
    'url': isDevEnvironment() ? 'http://nfp.localhost/dev' : 'https://nfp.wolnosciowiec.net'
  }
})

const pageFetcher = new PageFetcher(backend)

// Enable devtools
Vue.config.devtools = true
sync(store, router)

const nprogress = new NProgress({ parent: '.nprogress-container' })

const app = new Vue({
  router,
  store,
  nprogress,
  ...App,
  beforeCreate: function () {
    pageFetcher.setStore(this.$store)
    URLParametersManager.setParameters(this.$route.query)
  },
  watch: {
    $route () {
      URLParametersManager.setParameters(this.$route.query)
    }
  },
  provide: {
    'backend': backend,
    'pageFetcher': pageFetcher,
    'parameterManager': URLParametersManager
  }
})

export { app, router, store }

FormMapper.js

Maps attributes from router (URL) to the HTML form.

Example:

FormMapper.mapForm(
  {
    'event_search_form[query]': 'form_query',
    'event_search_form[event_type][]': 'form_event_type',
    'event_search_form[start_date]': 'form_start_date',
    'event_search_form[end_date]': 'form_end_date',
    'event_search_form[place]': 'form_place',
    'event_search_form[city]': 'form_city',
    'event_search_form[country]': 'form_country',
    'when': 'form_when'
  },
  this.$refs.form,
  this.$route,
  this.$refs
)

BackendApi.js

Calls endpoints to get the data from backends. A simple HTTP client, based on the Axios.

this.backend.get({
  service: 'wolnosciowiec',
  path: '/api/events/overview/by-category',
  callback: function (response) {
    rThis.categories = response.data.data
    rThis.$store.commit('exportDataForPage', {
      'elements': response.data.data,
      'meta': {},
      'pageId': storeName,
      'collectionType': CollectionType
    })
  }
})

PageFetcher.js

It's a extended BackendApi with addition of the store support. You can group response objects into collection, so for example when a listing page will return "A", "B", "C" and then you want to see "A" in a different view then you can still access it from the store.

There are 3 store types:

  • vuex (data is erased after page refresh)
  • persistent (data kept forever, eg. a complete list of countries, does not need to be updated frequently)
  • session (same here, but will disappear after the browser will be closed)
this.pageFetcher.fetch({
  service: 'wolnosciowiec',
  path: '/api/information/' + pageId,
  collectionType: 'StaticPage',
  storeType: 'vuex',
  pageId: 'StaticPage_' + pageId,
  onComplete: function (response) {
    rThis.page = response.data.data
    rThis.isLoaderActive = false
  },
  onCached: function (data) {
    rThis.page = data[0]
    rThis.isLoaderActive = false
  },
  onElementsStore: function (response) { return [response.data.data] }
})

BackendProvider

An extension to the Vuex.

getPageData

Fetches previously cached page.

let data = this.$store.getters.getPageData(storeName, 'Post')

if (data.elements.length === 0) {
    // ...
}
getSingleElementData

Returns a single element from a page that was already cached.

exportDataForPage

Pushes data to the store, under a given pageId of specified collectionType, with some meta attributes like information about the pagination or some other elements that are additionally on the page.

rThis.$store.commit('exportDataForPage', {
  'elements': posts,
  'meta': response.data.pagination,
  'pageId': storeName,
  'collectionType': 'Post'
})