0.0.2 • Published 6 years ago

summers-domi-viewer v0.0.2

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Domi Viewer说明文档

v0.0.2

安装

npm install nview-domi-viewer --save  

初始化

var domiViewer = require('summers-domi-viewer');

依赖

const route=require("koa-route");
const staticCache = require('koa-static-cache');

如何使用

两个中间件,缺一不可

//Viewer静态网站 
//ex:http://www.channel-fy.com:xxxx/domi/index.html
app.use(staticCache(domi_viewer.getViewerPath(), {
    prefix: '/domi'
  }));   

//swagger文件查看地址
//ex:http://www.channel-fy.com:xxxx/swagger/swagger.yaml
app.use(route.get('/swagger/swagger.yaml', domi_viewer.swaggerFileHandler));

参数

  • context.domi object

    context为koa的上下文,用于各中间件交换数据。 context.domi为当前请求的配置文件

  • context.domi 数据结构

{
    name: 'channelfy', //当前应用名称
    domain: 'www.channel-fy.com', //当前应用域名
    pathFilter: '', //当前应用下path匹配规则
    api: 'F:\\api\\mic\\channelfy',  //当前应用api路径地址
    view: 'F:\\api\\view\\'  //当前应用view路径地址
}

注意

该中间件需要置于summers-domi中间件之前,若置于其之后有可能无法正常运行

如果您有更多疑问请咨询: MIC-UED.