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

korct

v1.0.9

Published

快速构建以koa 为服务端、react 为前端

Downloads

11

Readme

korct

快速生成以 koa2 为服务端、 以 react 为前端的项目,开箱即用:在 github 中查看

DeepScan grade Build Status NPM download 截图

server 特点:

  • 无需为每个 route 执行注册, springBoot 式体验:

    class UserController {
      /**
       * 依赖注入,注入userService
       */
      @Autowired()
      private userService: UserService;
    
      /**
       * get
       * restful 获取userId
       * @param userId string ==> ctx.param
       * @queryObj 获取query参数 ==> ctx.query
       * @queryItem 获取query参数中的某一个 ==> ctx.query[key]
       */
      @GetMapping('/user/:userId')
      async queryUser(@param('userId') userId: string): Promise<User> {
        return this.userService.queryUserById(userId);
      }
      /**
       * post
       * @request() 获取request ==> ctx.request.body
       */
      @PostMapping('/add-user')
      async insertUser(@request() user: User): Promise<User> {
        return this.userService.insertUser(user);
      }
    }
  • 完整的 log 功能,基于 log4js

 log/xx.log
 [INFO] 6424f40c-1958-4284-b4d7-5580ed9744ff GET /user/1623415519723 3ms req: {"userId":"1623415519723"} res: {"errorMessage":null,"errorCode":null,"errorStack":null,"data":{"name":"hello","userId":"1623415519723"},"success":true,"traceId":"6424f40c-1958-4284-b4d7-5580ed9744ff","pid":9580}
  • 完整的单元测试,jest
const request = require("supertest");

describe("Demo controller", () => {
  test("GET /user/1234", done => {
    request("http://localhost:3000/user")
      .get("/1234")
      .set("Accept", "application/json")
      .send()
      .expect("Content-Type", /json/)
      .expect(200)
      .then(response => {
        expect(response.body.success).toEqual(true);
        expect(response.body.data.userId).toBe("1234");
        done();
      })
      .catch(err => done(err));
  });
});

web 特点:

  • react 驱动
import React from "react";
import ReactDom from "react-dom";
import Logo from "./component/logo";
import Demo from "./component/demo";
import styles from "./styles.less";
import "./global.less";

const App: React.FC<any> = () => {
  return (
    <div className={styles.box}>
      <Logo />
      <Demo />
    </div>
  );
};

ReactDom.render(<App />, document.querySelector("#root"));
  • 可配置的 webpack
  • 集成 less、typescript 等 loader

文件目录

  • controller : 路由控制器
  • service : 业务逻辑层
  • common : 一工具(注解,DI 等)
  • config : 一些启动配置
  • class : 运行时启动
  • web : react 前端代码
  • test : 单元测试目录

目前已完成的功能/模块:

  • [x] 日志
  • [x] 路由注解
  • [x] 多进程
  • [x] 单元测试
  • [ ] 数据库支持,mysql、mongodb

如何使用 korct

npm i korct -g

korct create projectName

cd projectName && npm run init

run dev:
npm run dev

run test: npm run test

github