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

serverlib-fisher

v1.2.8

Published

serverlib project by koa

Downloads

36

Readme

serverlib-fisher

介绍

本库只是一个node服务端的基础库,支持插件方式使用功能。

更新列表

安装教程

npm i serverlib-fisher --save

基础插件:

PlusHttpServer  基于koa的http服务插件
PlusRedis       redis
PlusSequelize   基于sequelize的orm数据库插件
PlusSchedule    计划任务插件

启动服务 new App().start();

服务启动参数说明

启动命令node App.js --env=prod --port=1000 env代表环境,会根据不同的环境加载根目录下不同的config_${env}.json文件 port代表监听的服务端口 所有启动参数都在processArg对象上,结构参照--key=value

config结构说明

{
    "sql": {
        "options": {
            "host": "xxx.xxx.xxx.xxx",
            "port": "端口",
            "dialect": "mssql或者mysql"
        },
        "dbName": "db名",
        "user": "用户用",
        "pwd": "密码"
    },
    "redis": {
        "port": 6379,
        "host": "127.0.0.1",
        "db": 0
    },
    "port": 1000            //监听的端口,如果启动命令带了端口,则使用启动命令的
    "logLevels": {                      //通过修改default的日志等级,可以在服务开启的情况下调整日志级别。  日志服务使用的是log4js
        "default": "ALL"
    },
    "logConfig": {                  //增加自定义的日志口子
        "appenders": {
            "clientLog": {
                "type": "dateFile",
                "filename": "${workspace}/logs/client/client",
                "pattern": "yyyy-MM-dd.log",
                "alwaysIncludePattern": true,
                "daysToKeep": 30
            }
        },
        "categories": {
            "clientLog": {
                "appenders": [
                    "clientLog",
                    "console"
                ],
                "level": "INFO"
            }
        }
    },
    "koa":{
        proxy:false,                 //是否有代理,默认false
        subdomainOffset:2,        //子域偏移量,默认2
        proxyIpHeader:X-Forwarded-F,          //代理ip头,默认为X-Forwarded-F
        maxIpsCount:0,            //从代理ip头读取的最大ip数,默认为0(表示无穷大)
        env:any,
        keys:any                       //签名cookie密钥
    }
}

插件使用说明

PlusSchedule

计划任务的文件都必须放在schedule目录下,文件结构如下

import { ScheduleBase } from "../base/plus/schedule/ScheduleBase";

export class ScheduleEveryDay extends ScheduleBase {
    get config() {
        return {
            cron: "0 0 0 * * *" //每日0点
        };
    }

    protected async mExecute() {
        //这些写计划任务的内容
    }
}

PlusHttpServer

作为基于http服务插件,所有接口都放在controller下建文件导出对象,文件形式如下

import { BaseService } from "../base/plus/httpServer/BaseService";

export class GmServer extends BaseService {
    constructor() {
        super();
        this._regist(this.func,"post", "gmAuthorize");      //post可以是get,最后一个参数可以不传,则接口cmd就是${文件名}/${方法名}
    }

    async func(a1,a2,a3){       //这里的参数key名就是访问接口对象中的key
        //这里写接口逻辑
    }
}

对外接口的访问结构如下: http://serverUrl/cmd

a1:xxx,
a2:xx,
a3:xxx

返回结构如下:

code:number;               //正常为200,其余都是异常
msg:string;                //异常信息描述
data:any;                  //返回内容数据

PlusSequelize

作为数据库组件,所有model对象都必须放在model目录下,文件结构如下:

import { ModelConfigBase } from "../base/plus/sequelize/ModelConfigBase";
import { ModelBase } from "../base/plus/sequelize/ModelBase";
import { DataTypes } from "sequelize";

export class ModelGameConfig extends ModelConfigBase {
    static readonly TABLE_NAME: string = "config_base_game";
    protected mInit() {
        this.mNeedSync = false;
        this.mAddAttr("id", { type: DataTypes.INTEGER, primaryKey: true });
        this.mAddAttr("name", DataTypes.STRING(64));
        this.mAddAttr("status", DataTypes.INTEGER);
        super.mInit();
    }
}

export class ModelGame extends ModelBase {
    id: number;
    name:string;
    status:number
}