1 Star 0 Fork 78

jiaolongshenme/Easy-Mock

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
router-config.js 1.84 KB
一键复制 编辑 原始数据 按行查看 历史
chuangker 提交于 2017-12-28 15:16 . feat(server): use redis
'use strict'
const config = require('config')
const Router = require('koa-router')
const restc = require('restc').koa2()
const ratelimit = require('koa-ratelimit')
const {
user,
mock,
util,
group,
project,
dashboard
} = require('./controllers')
const baseUtil = require('./util')
const middleware = require('./middlewares')
const rateLimitConf = config.get('rateLimit')
const apiRouter = new Router({ prefix: '/api' })
const mockRouter = new Router({ prefix: '/mock' })
const rate = ratelimit({
db: baseUtil.getRedis(),
id: ctx => ctx.url,
max: rateLimitConf.max,
duration: rateLimitConf.duration,
errorMessage: 'Sometimes You Just Have to Slow Down.',
headers: {
remaining: 'Rate-Limit-Remaining',
reset: 'Rate-Limit-Reset',
total: 'Rate-Limit-Total'
}
})
exports.mock = mockRouter
.all('*', middleware.mockFilter, rate, restc, mock.getMockAPI)
exports.api = apiRouter
.get('/wallpaper', util.wallpaper)
.post('/upload', util.upload)
.get('/dashboard', dashboard.list)
.get('/u', user.list)
.post('/u/login', user.login)
.post('/u/update', user.update)
.post('/u/register', user.register)
.get('/group', group.list)
.post('/group/join', group.join)
.post('/group/create', group.create)
.post('/group/delete', group.delete)
.post('/group/update', group.update)
.get('/project', project.list)
.post('/project/copy', project.copy)
.post('/project/create', project.create)
.post('/project/update', project.update)
.post('/project/delete', project.delete)
.post('/project/sync/swagger', project.syncSwagger)
.post('/project/update_workbench', project.updateWorkbench)
.get('/mock', mock.list)
.get('/mock/by_projects', mock.getAPIByProjectIds)
.post('/mock/create', mock.create)
.post('/mock/update', mock.update)
.post('/mock/delete', mock.delete)
.post('/mock/export', mock.exportAPI)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/uixepm/Easy-Mock.git
git@gitee.com:uixepm/Easy-Mock.git
uixepm
Easy-Mock
Easy-Mock
dev

搜索帮助