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

inspect-tool-platform

v0.0.6

Published

- 这是一个用于检查服务健康状态的工具平台

Downloads

2

Readme

检查服务工具

  • 这是一个用于检查服务健康状态的工具平台

使用 cli

  • 安装依赖 npm install inspecttools --save-dev or yarn add inspecttools --dev
  • 在当前项目下运行 npx itp -d 命令,执行默认检查
  • 在当前项目下运行 npx itp -s <strategyPath> 命令,增加自定义策略
  • 在当前项目下运行 npx itp -o <outfilePath> 命令,指定输出运行检查结果报告文件地址

提供了默认的策略

  1. API服务健康检查,接口检查,仅支持请求
  2. 文件或者文件夹存在检查
  3. 内存使用情况、系统配置情况、网络配置情况检查

默认策略配置文件

  1. package.json 的属性 strategyConfig 中配置相关属性
  2. 在项目根目录下添加配置文件strategy.config.js 或者 strategy.config.json文件

API服务健康检查 需要的配置

    // API服务器地址, 例如:https://www.baidu.com:3000/ditu
    CHECK_API_SERVER?: string 
    // API接口列表,例如["/list", "https://www.baidu.com:3000/ditu/users/list"]
    CHECK_API_LIST?: Array<string>

文件或者文件夹存在检查

    // 文件或文件夹的路径地址
    CHECK_EXIST_TO_FILE_OR_FOLDERS?: Array<string>

自定义策略 javascript

    import { InspectToolPlatform } from 'inspecttools'
    import { MyStrategy } from './mystrategy'

    // 实例化工具类
    const inspectToolPlatform = new InspectToolPlatform()

    // 增加自己的检查项目的实例
    await inspectToolPlatform.addStrategy(new MyStrategy())

    //运行检查程序
    await inspectToolPlatform.run()

    // 输出检查报告到指定的文件中
    await inspectToolPlatform.getReportsForFile('./myreport.json')

mystrategy.ts 文件

import { IStrategy, IResultReport, ICResultReport, Utils } from 'inspecttools'

interface IPCResultReport extends ICResultReport {
    desc: string
}
interface IPResultReport extends IResultReport {
    env: 'test' | 'production' | 'development'
}
export class Strategy implements IStrategy {
    public name: string = 'mystrategy'
    private _report:IPResultReport = {
        env: 'development',
        name: this.name,
        startTime: new Date(),
        endTime: undefined,
        loadding: true,
        status: false,
        reports: [],
    }
    private _root:string = process.cwd()
    protected setReport(report: ICResultReport): void {
        this._report?.reports?.push(report)
    }

    public getReport(): IResultReport {
        if (this._report.loadding) {
            console.error('检查未结束')
            return this._report;
        }
        return this._report
    }

    // 运行策略
    public async run () {
        
        // todolist
        await Promise.all([
            this.run1(),
            this.run2(),
            this.run3(),
            ...
        ])

        this.setReportStatus()
        this.setLoading(false)
        this._report.endTime = new Date()
    }
    private setReportStatus():void {
        this._report.status = !this._report.reports.find(r => r.status === false)
    }
    private setLoading(loading: boolean):void {
        this._report.loadding = !!loading
    }

    protected async run1(): Promise<void> {
        ...
        ...

        this.setReport({
            name: 'check project 1',
            status: true,
            desc: 'desc',
            data: {}
        } as IPCResultReport)
    }
    protected async run2(): Promise<void> {
        ... 
        ... 

        this.setReport({ 
            name: 'check project 2', 
            status: true,
            data: {}
        })
    }
    protected async run3(): Promise<void> {
        ...
        ...

        this.setReport({ 
            name: 'check project 3', 
            status: true,
            data: {}
        })
    }
}