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

@a4sex/api-resource

v2.6.1

Published

Api Resource mixin for freedomsex project.

Downloads

5

Readme

Api Resource

Api Resource mixin for freedomsex project. Depend axios, axios-rest-api

Настройка

Путем указания параметров DATA расширяемого компонетна.

    resource: {
      name: 'users', // Имя ресурса
      isPublic: true, // Нужна ли авторизация
      params: {
        id: null // Идентификатор ресурса
      },
    },
    subresource: {
      name: 'invites' 
      // Суб ресурс (/api/resurce_name/10/sub_resurce_name)
      // Пример /api/users/10/likes
    },

resource.name - если указвн, можно не указывать name в методах resource.params.id - если указан, можно не указывать id в методах

Методы

Общие

Если указан ID получает объект, иначе список. Онисание в методах далее

restoreData([name]) - restoreItem|restoreList

storeCached([name]) - storeCachedItem|storeCachedList

restoreCached([name]) - restoreCachedItem|restoreCachedList

reloadCached([id], [name]) - reloadCachedItem|reloadCachedList

refreshCached([id], [name], [hard]) - refreshCachedItem|refreshCachedList

Ресурс

async loadCached([id], [name], [force]) - получить объект по ID из кэша или загрузить если отсутствует. force - загрузить несмотря ни на что

loadCachedItem([id], [name], [force]) - получить объект по ID из кэша, если отсутствует или шаблонный

async restoreItem([name]) - получить объект из кэша несмотря ни на что

restoreCachedItem([name]) - сохранить список в кэш при условии, если есть и не шаблонный

async refreshCachedItem([id], [name], [hard]) - загрузить несмотря ни на что и сохранить. hard - игнорировать существующие данные

Список

async cachedList(name, force) - получить список из кэша или загрузить если список отсутствует или пустой. force - загрузить несмотря ни на что

loadCachedList([name], [force]) - получить список из кэша, если список пустой или шаблонный

reloadCachedList([name]) - сохранить список в кэш при условии, если есть и не шаблонный, и получить список из кэша, если список пустой или шаблонный

async restoreList([name]) - получить список из кэша несмотря ни на что

storeCachedList([name]) - сохранить список в кэш как есть

restoreCachedList([name]) - сохранить список в кэш при условии, если есть и не шаблонный

async refreshCachedList([name], [hard]) - загрузить несмотря ни на что и сохранить. hard - игнорировать существующие данные

Костыли

handleResource() - метод загрузки по умолчанию. Default: load - не кэширующая загрузка. Можно заменить на refreshCached

onWatchQuery() - метод вызываемый при изменении строки адреса. Default: handleResource

      isPublic: false,
      getPublic: false,
      putPublic: false,
      postPublic: false,
      deletePublic: false,