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

huajs-node

v0.2.3

Published

当前项目已发布到npm包管理 [huajs-node](https://www.npmjs.com/package/huajs-node)

Downloads

70

Readme

Npm 包

当前项目已发布到npm包管理 huajs-node

介绍

huajs-node 是一个基于 ES6,使用 TypeScript 编写的 nodejs 服务端框架

内核为 fastify.js,数据库连接为 knex.js

0.2.0 更新内容

  1. 系统将原生支持多项目层级
  2. model 和 service 方法第一个参数是项目主目录,必填,为了让这两个层级可以跨项目执行
  3. 在 controller 中执行 this.dop() 可直接获取对应的 domain 目录
  4. 在 config 中 adapter 内 controller 是用来配置多项目的 controller 的别名和主目录的

请注意:当更新到0.2后需要重新确定项目结构

安装教程

  1. 创建项目文件夹
  2. 参考源码中的test文件夹,创建config、controller、domain、service、model文件夹,以及index.ts
  3. npm install huajs-node --save
  4. npm run tsc // 将ts文件编译为js文件
  5. npm run start // 启动框架

框架解释

  1. 任何在 controller 内存在的后缀为 Action 的函数都会对外暴露
  2. domain 为逻辑层,目录结构与 controller 层完全一致,在 controller 中,能且只能执行对应的 domain 层方法
  3. controller 中只做简单的数据校验,复杂逻辑交给 domain 层来处理
  4. 在domain 层中,可以执行任意目录的 service 层和 model 层方法
  5. service 是服务层,一般用来存放公共方法
  6. model 为模型层,能且只能执行数据库方法

框架目录

├── README.md                            // readme
├── package.js                           // 版本管理
├── tsconfig.js                          // TypeScript 控制
├── src                                  // 代码目录
│   ├── lib                              // 框架源代码
│   │   ├── config                       // 配置目录
│   │   │   ├── adapter.ts               // 配置
│   │   │   └── config.ts                // 配置信息
│   │   ├── core                         // 代码目录
│   │   │   ├── layer                    // 层
│   │   │   │   ├── base.ts              // 层级 基础继承
│   │   │   │   ├── controller.ts        // 控制层实现
│   │   │   │   ├── domain.ts            // 逻辑层实现 ( domain 领域驱动开发 )
│   │   │   │   ├── model.ts             // 模型层实现
│   │   │   │   └── service.ts           // 服务层实现
│   │   │   └── methods                  // 方法
│   │   │   │   ├── hook.ts              // 钩子
│   │   │   │   └── router.ts            // 配置路由信息
│   │   ├── extend                       // 框架继承目录
│   │   │   ├── helper.ts                // 继承基础方法
│   │   │   ├── hua-cache.ts             // 继承缓存
│   │   │   ├── hua-mysql.ts             // 继承数据库
│   │   │   └── hua-rabbitmq.ts          // 继承延时队列
│   │   ├── application.ts               // 框架继承入口
│   │   └── hua.ts                       // 框架启动入口
│   └── test                             // 单元测试代码

如上,由框架约定的目录:

  1. dist文件夹为ts编译成的js文件,框架在此目录内执行
  2. src文件夹为ts文件,编写功能的目录,如要修改请在此文件夹内修改
  3. src/lib 是框架代码目录,不建议直接修改
  4. src/test 是单元测试目录,可在此文件夹内测试框架各项功能
  5. src/test/config 配置文件目录 (可选)
  6. src/test/index 入口文件,必须使用 new Application().start() 来启动框架