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

kisa-typegen

v0.3.2

Published

Generate api.d.ts for kisa

Downloads

4

Readme

kisa-typgen

Generate api.ts for kisa

Get Started

  1. install tool
npm i -g kisa-typegen
  1. prepare openapi file
{
  @openapi({
    servers: [
      {
        url: "http://localhost:3000",
      }
    ],
    security: [
      { jwt: [] }
    ]
  })
  login: { @endpoint({summary:"user login",security:[]})
    route: 'POST /login',
    req: {
      body: {
        name: 'admin',
        pass: 'a123456'
      }
    },
    res: {
      200: {
        id: 1,
        name: 'user1',
        token: '<token>',
        expireAt: '<timestamp>'
      }
    }
  },
  createPost: { @endpoint({summary:"create post", "x-middlewares": ["ratelimit"]})
    route: 'POST /posts',
    req: {
      body: {
        title: 'How to write blog?',
        description: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry', @optional
        content: `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever`,
      }
    },
    res: {
      200: { @save("Post")
        id: 1,
        userId: 1,
        title: 'How to write blog?',
        description: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry',
        status: 0,
        content: `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever`,
        createdAt: "<datetime>",
        updateAt: "<datetime>",
      }
    },
  },
  publishPost: { @endpoint({summary:"publish post"})
    route: "PUT /posts/{}/publish",
    req: {
      params: {
        id: 1
      }
    },
    res: {
      200: {
        msg: "OK",
      }
    },
  },
  listMyPosts: { @endpoint({summary:"list my posts"})
    route: "GET /posts/my",
    req: {
      query: {
        pageSize: 0, @optional
        pageNum: 10, @optional
      }
    },
    res: {
      200: [
        { @use("Post")
        }
      ]
    }
  },
  listPosts: { @endpoint({summary:"list posts",security:[]})
    route: "GET /posts",
    req: {
      query: {
        pageSize: 0, @optional
        pageNum: 10, @optional
      }
    },
    res: {
      200: [
        { @use("Post")
        }
      ]
    }
  },
  deletePost: { @endpoint({summary:"delete post"})
    route: "DELETE /posts/{}",
    req: {
      params: {
        id: 1
      }
    },
    res: {
      200: {
        msg: "OK"
      }
    }
  }
}
  1. generate api.ts
kisa-typgen api.jsona api.ts

content of api.ts

/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */

import {
  Handler,
  Middleware,
  Operation,
  Handlers as KisaHandlers,
  Middlewares as KisaMiddlewares,
  SecurityHandlers as KisaSecurityHandlers,
} from "kisa";

export namespace ReqTypes {
  export interface Login {
    body: {
      name: string;
      pass: string;
    };
  }
  export interface ListPosts {
    query: {
      pageSize?: number;
      pageNum?: number;
    };
  }
  export interface CreatePost {
    body: {
      title: string;
      description?: string;
      content: string;
    };
  }
  export interface PublishPost {
    params: {
      id: number;
    };
  }
  export interface ListMyPosts {
    query: {
      pageSize?: number;
      pageNum?: number;
    };
  }
  export interface DeletePost {
    params: {
      id: number;
    };
  }
  export interface Post {
    id: number;
    userId: number;
    title: string;
    description: string;
    status: number;
    content: string;
    createdAt: string;
    updateAt: string;
  }
}

export interface Handlers<S> extends KisaHandlers<S> {
  login: Handler<S, ReqTypes.Login>;
  listPosts: Handler<S, ReqTypes.ListPosts>;
  createPost: Handler<S, ReqTypes.CreatePost>;
  publishPost: Handler<S, ReqTypes.PublishPost>;
  listMyPosts: Handler<S, ReqTypes.ListMyPosts>;
  deletePost: Handler<S, ReqTypes.DeletePost>;
}

export interface Middlewares<S> extends KisaMiddlewares<S> {
  ratelimit: Middleware<S>;
}

export interface SecurityHandlers<S> extends KisaSecurityHandlers<S> {
  jwt: (config: string[]) => Middleware<S>;
}

export const OPERATIONS: Operation[] = [....];