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 🙏

© 2025 – Pkg Stats / Ryan Hefner

little-star-connect

v0.3.6

Published

a api generate cli

Readme

a CLI util to generate doc-like api.ts file

  • how to use
npm i little-star-connect -g 

otterf
or
npm i little-star-connect 

npx otterf
  • how to run in dev-environment

git clone [email protected]:skr305/little-star-connect.git

npm i

npm run dev
  • by ts-node cli.ts yield, you can generate api.ts by set options

  • based on commander, you can use npm run help to get help

  • use .\scripts\ci or ./scripts/ci.sh to integration

  • by write a *.dog file like
    login  { id, pwd }  { id, avatar, nick } 
    reg  { r_id, r_pwd }  { n_id, n_nick } 
  • can generate react/vue hooks to fetch data easily ( by the -r/-v options )

  • the result is like ( including some usable hooks )


/**
 * 
 * @file react-hook生成的模板参照
 * @author otterh
 * @date 2022-06-28 23:51
 * 
 */

 import { useState } from 'react'

 // 默认OK代表成功处理请求
 enum AppErrorCode {
     
     OK = 0,
     
     // 1 - 998 为保留码
 
     ConnectionFail = 999
 
 }
 
 // 作为App中Error的标准格式
 type AppError< T = any > = {
     message: string
     data: T
     errorCode: AppErrorCode
 }
 
 // 需要注入的fetch类型
 type OtterFetch = <P, R>( url: string, params: P ) => Promise< AppError<R> >
 
 // 作为模板的一个api元信息 
 // 无实际意义
 type LoginParams = { id: string }
 
 type LoginResponse = { avatar: Buffer }
 
 const LoginURL = "/login"
 
 /**
  * 
  * @param url 请求的地址
  * @param _fetch 请求方法
  * @returns 生成的针对该接口的hook
  */
 const hookGenerator = < P, R >( url: string, _fetch: OtterFetch ) => {
     
    /**
     * @param params 注入的请求参数
     * @return { [ data, error, loading, setData, setError, setLoading ] } 
     */
     return ( params: P ) => {
         
         // 生成对应的3种状态
         // [ data-error-loading ]
         // 根据不同状态决定页面的展示逻辑
         const [ data, setData ] = useState<R>()
         const [ error, setError ] = useState<AppError>()
         const [ loading, setLoading ] = useState<boolean>( true )
 
         _fetch< P, R >( url, params )
         .then( response => {
             if( response.errorCode === AppErrorCode.OK ) {
                setData ( response.data )
             } else {
                 // 如果不是OK的状态码
                 // 则代表处理出现了问题
                 setError( response )
             }      
         } )
         .catch( () => {
            setError( {
                data: {},
                message: "connection fail," +
                " it may not be the matter of the server",
                errorCode: AppErrorCode.ConnectionFail
            } )
         } )
         .finally( () => {
            setLoading( false )
         } )

         return [ 
            data,
            error, 
            loading, 
            setData, 
            setError, 
            setLoading 
        ]
     }
 
 }
 
 // 生成的hook的类型
 type OtterHookType< P, R > = ReturnType< typeof hookGenerator< P, R > > 
 
 export default class VueFetchHook {
 
     public _fetch: OtterFetch
     public useLogin: OtterHookType< LoginParams, LoginResponse >
 
     constructor( _fetch: OtterFetch ) {
         this._fetch = _fetch
         this.useLogin = hookGenerator< LoginParams, LoginResponse >( LoginURL, this._fetch )
     }
 
 }