-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathinit.js
More file actions
44 lines (41 loc) · 1.15 KB
/
init.js
File metadata and controls
44 lines (41 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const logger = require('./nkcModules/logger');
async function InitDefaultData() {
logger.info(`初始化默认数据...`);
const defaultData = require('./defaultData');
await defaultData.init();
logger.info(`完成`);
}
async function InitOperations() {
logger.info('初始化管理员权限...');
const { DynamicOperations } = require('./settings/operations.js');
// 运维包含所有的操作权限
const operationsId = Object.values(DynamicOperations);
const { RoleModel, ForumModel } = require('./dataModels');
await RoleModel.updateOne(
{ _id: 'dev' },
{ $set: { operationsId: operationsId } },
);
await ForumModel.updateMany({}, { $addToSet: { rolesId: 'dev' } });
logger.info(`完成`);
}
async function InitCache() {
logger.info(`初始化缓存...`);
const cacheBaseInfo = require('./redis/cache');
await cacheBaseInfo();
logger.info(`完成`);
}
InitDefaultData()
.then(() => {
return InitOperations();
})
.then(() => {
return InitCache();
})
.then(() => {
logger.info(`初始化完成`);
process.exit(0);
})
.catch((err) => {
logger.error(err);
logger.error('初始化失败');
});