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

@ncf/core

v0.0.5

Published

nodejs concise framework

Downloads

2

Readme

这里面是架构核心。

  • serviceHub
  • serviceLoader 扫描 services 目录并且加载模块,热更新模块
    • 调用 config.js 中配置的 extension map,如 .sql 使用 osql-loader 或者 psql-loader, 没有注册的就认为是默认 js,取 exports.faas 作为服务,exports.xxx 作为该服务的配置
  • 如何实现服务端视图?
    • exports.faas 取视图用到的数据
    • exports.view 设置从哪个视图渲染
    • view 模块使用 view-loader 预编译变成函数
    • middleware 执行完 faas 后,将结果带入到配置的 view fn 结果返回
  • 如何区分 internal/对外
    • config 中配置哪些扫描,其中哪些对外
    • 可以整个目录配置成只对内,如 view 视图模板目录,只对内

config.js 范例

exports.loader = {
  sql: require('osql-loader'),
  md: require('md-loader'),
  json5: require('json5-loader'),
}
exports.loader = (ext, filename) => {
  if (ext === 'sql') {
    return require('osql-loader');
  }
}

配置结果参考

root
  dir1
    middlewares
    loaders 没设置自动取上级,设置可以取上级并修改,this.parent 可以取到上级
    subdirs
    services
    aliases

路由过程, path 切分段落 先看第一段,执行 middlewares, 找目录或者文件,没有找 alias,最终定位到服务。 执行服务的 faas 方法,等待 promise 解析或报错。 中间件可以看到 req, resp, ctx.state;然后做出改变。ctx 没有关于 http 的信息。

todo

  • 实现服务自动注册机制
  • 实现 loader 机制,根据文件名,文件路径转成服务模块,带 faas 方法的过程
  • 实现中间件机制,改变请求响应,设置和提取中间状态
  • 配置,服务和中间件还有loader都能够读取 dir/file中的配置,loader 只能读 dir 中的配置
  • http gateway 能挂接到核心 core.service(path, request) => Promise

从简单到复杂

  • 实现 dirConfig prototype 链
    • 然后在实现 module 到所属目录的 dirConfig prototype
  • 实现 jsLoader, configLoader,
    • 然后再实现 markdown,yaml,json5
    • osql,psql 等 loader
    • 再实现 DSL loader
  • 实现 watch add
    • 实现 watch change
    • 实现 watch del
  • config.middlewares [] 实现中间件机制