You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

3 years ago
'use strict';
const routes = require('./routes');
3 years ago
const utils = require('./utils')
3 years ago
const redisConnect = require('./service/redis')
3 years ago
const socketConect = require('./service/socket')
3 years ago
const paasRequest = require('./service/paasRequest');
3 years ago
const authenticator = require('./middlewares/authenticator');
// const apiLog = require('./middlewares/api-log');
module.exports.entry = function (app, router, opts) {
3 years ago
app.fs.logger.log('info', '[FS-AUTH]', 'Inject auth and api mv into router.');
3 years ago
3 years ago
app.fs.api = app.fs.api || {};
3 years ago
app.fs.utils = app.fs.utils || {};
3 years ago
app.fs.api.authAttr = app.fs.api.authAttr || {};
app.fs.api.logAttr = app.fs.api.logAttr || {};
3 years ago
3 years ago
// 工具类函数
utils(app, opts)
3 years ago
// 顺序固定 ↓
redisConnect(app, opts)
socketConect(app, opts)
3 years ago
// 实例其他平台请求方法
paasRequest(app, opts)
3 years ago
// 鉴权中间件
3 years ago
router.use(authenticator(app, opts));
// 日志记录
3 years ago
// router.use(apiLog(app, opts));
router = routes(app, router, opts);
3 years ago
};
module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Sequelize, models: {} }
3 years ago
require('./models/camera_ability')(dc);
require('./models/camera_kind')(dc);
require('./models/camera')(dc);
require('./models/nvr')(dc);
require('./models/vender')(dc);
require('./models/ax_project')(dc);
3 years ago
};