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

peer.ts

v1.2.0

Published

convert your apib to typescript

Downloads

2

Readme

Peer.ts 1.2

1.2 版主要优化:

  1. 优化了配置文件, 提供了更灵活的编译方式.
  2. 优化了输出文件的格式, 更加的通用.

原理

apib文档 => swagger.json => 生成描述 ts 代码的json => 合成 Typescript 的代码及文件.

安装

1. 全局安装:

yarn global add peer.ts

cd 到有 peer.config.json 文件的目录, 运行 peer 即可.

2. 局部安装:

yarn add peer.ts --dev

在package.json 中 添加 npm script : "peer": "peer";

cd 到有 peer.config.json 文件的目录, 运行 yarn peer 即可.

Peer.ts 编译配置文件: peer.config.json

例如:

{
  "rootDir": ".",
  "loggerDir": "log",
  "nameConfig": {
    "input": "name.json",
    "output": "name.json"
  },
  "apibPath": "todo.apib",
  "output": {
    "apiFileName": "TestApi",
    "dataFileName": "TestData",
    "urlFileName": "Url"
  },
  "exceptHeaders": {
    "Content-Type": "annotation"
  }
}

各个字段的介绍:

  1. rootDir , 相对于当前运行路径的编译路径, 其他配置项的路径都相对于这个路径.
  2. loggerDir, 日志的路径.
  3. apibPath, 接口文档的输入路径.
  4. output, 输出的 TypeScript文件 的名字配置.
  5. exceptHeaders , 需要忽略的http请求头. 忽略模式目前只可以选择 "annotation" --- 注释的方式.

nameConfig. 名字的配置文件, 即接口的英文名配置.

第一次运行 peer 进行解析时, 会自动生成初始的命名配置表.

命名配置表的输入输出为同一个文件时可以直接修改这个文件, 输出入和输出会智能合并, 不会发生简单的覆盖

apib 文档编写的注意事项:

1. 数组的类型描述:

✅: RoomOrderList (array, fixed-type),

❌: RoomOrderList (array, fixed);

2. 不可以有中文的标点符号.

Peer.ts 的待办事项:

  • [ ] 生成 数据的 mock 函数
  • [ ] 使用json schema 测试 api 接口.