1.5.11 • Published 1 year ago

egg-qeelyn-framework v1.5.11

Weekly downloads
3
License
MIT
Repository
github
Last release
1 year ago

eggjs qeelyn framework

基于eggjs整理了一套服务端框架

具体引用

npm i egg-qeelyn-framework --S

再package.json中增加

{
    ...
    "egg": {
        "framework": "egg-qeelyn-framework"
    },
    ...
}

VS CODE

使用 vs code 开发 建议安装插件eggjs

已启动的功能

  1. 默认配置了json日志输出
  2. redis (目前redis,外部项目需要自己配置)
  3. 加载框架的controller (给vue框架公共区域调用的api、spm创建的api、注销用户api、前端日志记录)
  4. 中间件的引入 (api用户验证、spm跨系统服务)
  5. service (统一的http请求格式封装、邮件发送、登陆验证中心接口、spm的创建使用)
  6. 工具类 (可以统一的json格式输出)

controllser

介绍

框架controllser是前端模块配合调用的api接口层,主要用处理公共头部的接口、spm的创建接口、用户注销的logout接口,当然也可以自行实现

使用方式

路由配置即可使用。 (copy过去就可以了)

    // 前端公共部分ui的api
    router.post('/qeelyn-framework/usercenter-api', controller.qeelynFrameworkApi.ucenterApi);
    // 注销api
    router.get('/qeelyn-framework/logout', controller.qeelynFrameworkApi.logout);
    // 前端日志记录使用
    router.get('/qeelyn-framework/log', controller.qeelynFrameworkApi.log);
    // spm生产api   spm的使用需要配置redis
    router.post('/qeelyn-framework/spm', controller.qeelynFrameworkApi.spm);

extend

介绍

规范 输出和某种特定请求的获取

使用方式 helper.js

具体内容说明在对应文件中可以查看

    //规范输出
    ctx.helper.jsonResult(data, error)
    ctx.helper.errorOut(errors)
    //特殊格式获取
    ctx.helper.getQueryData(query, method)

使用方式 context.js

    //日志的json输出  (目前废弃)
    ctx.logger
    //真实ip获取 会获取代理中的x-forwarded-for
    ctx.xip
    //处理生成reqId
    ctx.reqId

middleware

介绍

middleware是和路由配合,在子系统的路由中调用。主要处理api的jwt验证、spm的用户服务、记录request log、防重、防串改签名验证

jwt验证需要一个 rsa_pub.pem 的解密文件 放在子系统的app目录下

使用方式

在路由中使用 具体内容说明在对应文件中可以查看

    // 用于api处理
    const qeelynApiAuth = app.middleware.qeelynApiAuth(),
        qeelynValidSign = app.middleware.qeelynValidSign(),
        qeelynLog = app.middleware.qeelynLog();
    router.post('/api/xxx',qeelynValidSign, qeelynLog, qeelynApiAuth, controller.api.api);

    // 用于页面路由处理
    const qeelynSpmAuth = app.middleware.qeelynSpmAuth(),
        qeelynPageAuth = app.middleware.qeelynPageAuth();
    router.get('/*',qeelynSpmAuth, qeelynPageAuth, controller.home.index);

service

介绍

框架service提供一些可以给系统调用的service 主要有 统一的qeelyn服务端模拟http请求、邮件发送、用户登陆和信息查询服务、spm服务

使用方式

具体内容说明在对应文件中可以查看

    //举了个例子
    const body = await this.service.qeelynSpmClient.createSpm();

config

配置文件 config.default.js 具体已再文件内备注好

    //针对自己的系统定义一个appCode(必须配置)
    config.appCode = '';

    //发送邮件需要配置
    config.mailer={};

单元测试

可参考eggjs的单元测试 本项目的单元测试目录在test下,运行如下代码可以进行单元测试:

    npm run test-local  xxxx(代表test对应目录文件)
    npm run test-local test/service/qeelynSpmClient.test.js

运行时需要再test\fixtures\example\config增加 config.unittest.js

'use strict';
const path = require('path');

module.exports = {
    //公钥的位置
    publicKeyPath: path.join(__dirname, 'rsa_pub.pem'),
    api: {
        deoGateway: 'xxx',
        ucenterAuth: 'xxx',
    },
    keys: 'xxx',
    mailer: {
        host: 'smtp.exmail.qq.com',
        user: 'xxx',
        pass: '',
        port: '465',
    },
    cache: {
        redis: {
            type: 'Redis',
            port: xxx,
            host: 'xxx',
            db: 0,
        },
    },
    appCodeLogin: {
        'deo.backend': 'http://xxx'
    },
    pageConfig: {
        loginUrl: 'http://xxx'
    },
};
1.5.10

1 year ago

1.5.11

1 year ago

1.5.9

2 years ago

1.5.8

2 years ago

1.5.7

2 years ago

1.5.6

2 years ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.17

3 years ago

1.4.16

3 years ago

1.4.15

3 years ago

1.4.14

3 years ago

1.4.13

3 years ago

1.4.12

3 years ago

1.4.11

3 years ago

1.4.10

3 years ago

1.4.9

3 years ago

1.4.8

4 years ago

1.4.7

4 years ago

1.4.6

4 years ago

1.4.5

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.47

4 years ago

1.3.46

4 years ago

1.3.45

4 years ago

1.3.44

4 years ago

1.3.43

4 years ago

1.3.42

4 years ago

1.3.41

4 years ago

1.3.40

4 years ago

1.3.39

5 years ago

1.3.38

5 years ago

1.3.37

5 years ago

1.3.36

5 years ago

1.3.35

5 years ago

1.3.34

5 years ago

1.3.33

5 years ago

1.3.32

5 years ago

1.3.31

5 years ago

1.3.30

5 years ago

1.3.29

5 years ago

1.3.28

5 years ago

1.3.27

5 years ago

1.3.26

5 years ago

1.3.25

5 years ago

1.3.24

5 years ago

1.3.23

5 years ago

1.3.22

5 years ago

1.3.21

5 years ago

1.3.20

5 years ago

1.3.19

5 years ago

1.3.18

5 years ago

1.3.17

5 years ago

1.3.16

5 years ago

1.3.15

5 years ago

1.3.14

5 years ago

1.3.13

5 years ago

1.3.12

5 years ago

1.3.11

5 years ago

1.3.10

5 years ago

1.3.9

5 years ago

1.3.8

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago