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

sav

v1.0.42

Published

sav

Downloads

48

Readme

sav

sav-core

核心模块 cookie header request response socket

sav-decorator

装饰器

sav-prop

模块注入

sav-router

路由

sav-dataset

nosql数据库

sav-database

sql数据库

sav-cache

缓存

sav-view

页面渲染

sav-vue

vue页面渲染

层次结构

app ctx request response

    req.headers
        req.cookies
    req.body

    res.headers
    res.body
    res.status

socket
services

class Article {
    @get('article/:aid')
    async get ({db, ds, service, params, self}) {
        let article = await ds.articles.findOne({aid: params.aid}).ensure()
        let auther = await db.table('users').where({uid: article.uid}).ensure()
        let comments = await service.get("article/comments", {aid: params.aid})
        let me = await self.user.me()
        return {
            me,
            article,
            auther
        }
    }

    @post('article/update/:aid')
    async update ({db, ds, service, session, params, throwExp, input}) {
        let article = await ds.articles.findOne({aid: params.aid}).ensure()
        if (session.uid !== article.uid) {
            throwExp(403)
        }
        article = await ds.articles.update(input).ensure()
        return {
            article
        }
    }
}

class User {
    async me ({cache, session}) {
        return await cache.getBy('user', session.uid)
    }
}

todo

开发工具打包 rollup webpack standard eslint ava nyc babel


装饰器提取后的模块格式

{
  "moduleName": "Account",
  "moduleGroup": "Page",
  "uri": "AccountPage",
  "props": {
    "view": "vue",
    "layout": "UserLayout"
  },
  "routes": [
    {
      "actionName": "login",
      "uri": "AccountPage.login",
      "tasks": [
        { "name": "title", "props": "登录" },
        { "name": "route", "props": {"methods": ["GET"]}}
      ]
    }
  ]
}

经由模块预处理插件(注入, 不会被序列化)
{
  "routes": [
    {
      "actionName": "login",
      "uri": "AccountPage.login",
      "tasks": [
        { "name": "title", "props": "登录" }, // 任务项
      ],
      module, // 双向绑定
      middlewares: [],
      appendMiddleware (name, middleware, prepend) {}
      props: { // 将tasks转换为props方便后续处理
        title: { // 任务项
          name: "title",
          props: "登录",

          middleware: null,
          setMiddleware (middleware) {}
        }
      }
    }
  ],

}

经由路由转换插件(添加)
{
  "SavRoute": {
    "uri": "AccountPage",
    "path": "/account",
    "childs": [
      {
        "uri": "AccountPage.login",
        "path": "/account/login",
        "methods": [
          "GET"
        ]
      }
    ],
    "parents": []
  },
  "VueRoute": {
    "component": "Account/Account",
    "path": "/account",
    "children": [
      {
        "component": "Account/AccountLogin",
        "name": "AccountLogin",
        "path": "login",
        "methods": [
          "GET"
        ]
      }
    ]
  }
}

sav要做什么

App = Page + Route Page = PageLayout + PageRoute + PageView PageLayout = Views View = Template + State + Route Route = Api + Schema State = Schema

=>

Page = Route + View + State Route = View = State

mapGetter => DataSource