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 🙏

© 2026 – Pkg Stats / Ryan Hefner

typescript-boot

v2.0.5

Published

typescript-boot, This is a scaffolding that allows you to quickly start developing api interface services using typescript

Downloads

173

Readme

typescript-boot

typescript-boot 是一个面向 TypeScript 后端项目的轻量脚手架,目标是让你用较少的样板代码,快速搭建并发布 HTTP API 服务与 WebSocket 服务。

它当前提供的核心能力包括:

  • HTTP 接口服务发布
  • WebSocket 服务发布
  • 在线接口文档
  • Session 与权限管理
  • Redis 接入
  • 数据库统一访问抽象与 MySQL 实现
  • 文件上传与下载
  • 邮件发送
  • 自定义行为日志

完整示例项目可参考:

  • https://github.com/seeksdream/typescript-boot-demo

安装

npm install typescript-boot reflect-metadata

如果你使用 TypeScript,请确保开启:

  • experimentalDecorators
  • emitDecoratorMetadata

并且在入口文件最先执行:

import 'reflect-metadata';

HTTP 快速开始

import 'reflect-metadata';
import {
  BaseService,
  SeeksWebServer,
  apiDoc,
  apiParamFromBody,
  apiPath,
  apiReturn
} from 'typescript-boot';

@apiDoc('账号服务')
@apiPath('/account')
class AccountService extends BaseService {
  @apiDoc('登录')
  @apiReturn('登录结果')
  @apiPath('login')
  async login(
    @apiParamFromBody('登录账号') account: string,
    @apiParamFromBody('登录密码') password: string
  ) {
    return this.success({
      account,
      token: 'demo-token'
    });
  }
}

const server = new SeeksWebServer(3333);
server.publishService(new AccountService());
server.start();

启动后可访问:

  • http://localhost:3333/account/login
  • http://localhost:3333/typescript-boot

WebSocket 快速开始

import 'reflect-metadata';
import {
  BaseSocketService,
  SeeksWebServer,
  apiPath
} from 'typescript-boot';

@apiPath('/chat')
class ChatSocketService extends BaseSocketService {
  async onConnected(client) {
    client.sendAction('connected', {
      clientId: client.id
    });
  }

  @apiPath('echo')
  async echo(client, data) {
    return this.success({
      echo: data
    });
  }
}

const server = new SeeksWebServer(3333);
server.publishSocketService(new ChatSocketService());
server.start();

客户端连接地址:

  • ws://localhost:3333/chat

客户端发送消息示例:

{
  "action": "echo",
  "requestId": "r1",
  "data": {
    "text": "hello"
  }
}

使用手册

建议按下面顺序阅读:

一些关键规则

  • 接口Service@apiPath() 只能使用单段路径,例如 /account
  • 接口方法@apiPath() 支持多段路径和变量路径,例如 oauth/:provider/authorizeUrl
  • 如果接口方法没有写 @apiPath(),默认使用方法名作为访问路径
  • BaseServiceBaseSocketService 中的普通实例方法会被视为可发布接口或动作,不建议把辅助函数直接写在 service 类里

在线文档

默认情况下,框架会自动发布在线文档页面:

  • http://localhost:端口/typescript-boot

效果如下:

简单示例效果图