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

@rockerjs/dao

v1.0.1

Published

Database access object framework, support transaction

Downloads

1

Readme

ROCKER-MVC

一、快速上手

初始化项目目录

  • 安装 Node.js(v8.9.3+)

    https://nodejs.org/en/

  • 安装 vbuilder 命令行

    [sudo] npm i @vdian/vbuilder-cli --registry http://npm.idcvdian.com
  • 进入项目目录(名称任意)

    mkdir rocker-mvc-project
    
    cd rocker-mvc-project
  • 执行命令 v,根据提示依次完成:项目初始化、启动本地开发环境

    项目初始化完成后,也可以执行 npm run dev 启动本地开发环境

启动开发环境

npm run dev

二、API

所有 API 挂载在引入的 MVC 对象下,而且可以串行调用

MVC.route({
    '/home': import('./home')
}).start()

start

接收参数:

  • { port: number }

在添加路由以及中间件后启动服务

MVC.pipe(middleWare).route({ }).start()

route

接收参数:

  • RouterMap => { [index: string]: Function } | { [index: string]: Promise };
  • RouterRegType => { all: RouterMap, render?: { start: string, end: string } }

为应用添加路由处理方法,参数示例如下:

// 1. RouterMap
MVC.route({
    '/home': import('./home'),
    '/about': import('./about')
})

// 2. RouterRegType
// 为所有的路由添加公有的 header 和 footer 脚本
MVC.route({
    all: {
        '/home': import('./home'),
        '/about': import('./about')
    },
    render: {
        start: './header.ejs',
        end: './footer.ejs'
    }
})

pipe

接收参数:

  • Koa 中间件

Rocker MVC 可以任意使用Koa的中间件,示例如下:

编写 logRequest 中间件

function log( ctx ) {
    console.log( ctx.method, ctx.header.host + ctx.url )
}

export default function () {
    return async function ( ctx, next ) {
        log(ctx);
        await next()
    }
}

通过 pipe 来引入中间件

import logRequest from './logRequest'

MVC.pipe(logRequest()).route({ }).start()

三、TypeScript 介绍

全局安装 typescript 编译器

npm i -g typescript

编写 ts 配置文件 tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noImplicitAny": false,
        "allowJs": true,
        "inlineSourceMap": true
    },
    "exclude": [
        "node_modules",
        "coverage"
    ]
}

执行编译操作

tsc .

四、TODO

  • route 现在只接收 import 进来的模块
  • 完善单元测试
  • 添加测试覆盖率
  • push 前挂载集成测试钩子