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

typescript-boot

v1.0.38

Published

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

Downloads

50

Readme

typescript-boot

这是一个可以帮助你用typescript快速开发后端API接口服务的脚手架。同时支持通过注解生成完全可供前端同学开发参考的在线接口文档。

里面提供了包括session会话管理、权限管理、日志管理的开箱即用功能,同时又支持完全自定义这些管理器。

还提供了方便操作数据库的方式,支持各种数据库(支持mysql、达梦数据库、其他数据库也很方便可以实现)。对数据库的操作支持对象映射。

以下是一个简单示例:

更多功能可以参考这个完整的、可运行的示例:https://github.com/seeksdream/typescript-boot-demo

1,首先安装依赖

npm install typescript-boot

2,编写代码

// 首先,编写一个接口服务:

@apiDoc('权限认证') // 描述服务名称
@apiPermission(NoRequiredPermission) // 设置访问当前接口服务的前置条件,如无需登录、需要登录、仅限指定角色登录等
@apiPath('/account') //设置访问此服务下的接口的前缀路径
export default class AccountService extends BaseService{
  @apiDoc('登录')
  @apiReturn('会话token(string)') // 描述返回结果中数据内容
  @apiPath('login') //结合服务路径/account,最终此接口的访问路径为:http://localhost:端口/account/login
  async login(
    @apiParamFromBody('登录账号') account:string, // 从body中获取account属性,并描述account的含义为:登录账号
    @apiParamFromBody('登录密码(MD5)') password:string, // 从body中获取password属性,并描述password的含义为:登录密码
    @apiRequest() req
  ) {
    // TODO 实现接口内容
    const token = '';
    return this.success(token);
  }
}

// 然后,在你的主程序中通过以下代码发布接口服务并启动

import 'reflect-metadata';
import {SeeksWebServer} from 'typescript-boot';
const port = 3333;
const server = new SeeksWebServer(port);
server.publishService(new AccountService()); // 注册一个api服务
server.start(); // 启动服务,然后就可以调用接口了


此刻,你的接口就可以被调用了。

同时,你还可以同通过以下链接来查看接口文档:

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

简单示例效果图