-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (29 loc) · 1.1 KB
/
index.js
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
require("dotenv").config();
const login = require("@app/login");
const { Sequelize, sequelize, Op } = require("@database");
const logger = require("@logger");
const { email, password, appStateFile } = require("@config");
const fs = require("fs");
const __GLOBAL = new Object({
threadBlocked: new Array(),
userBlocked: new Array(),
swearList: new Array(),
confirm: new Array(),
});
facebook = ({ Op, models }) => login({ email, password, appState: require(appStateFile) }, function (error, api) {
if (error) return logger(error, 2);
fs.writeFileSync(appStateFile, JSON.stringify(api.getAppState(), null, '\t'));
logger('Đăng nhập thành công!', 0);
//Listening
api.listen(require("@app/listen")({ api, Op, models, __GLOBAL }))
})
sequelize.authenticate()
.then(() => logger('Connect database thành công!', 0), () => logger('Connect database thất bại!', 2))
.then(() => {
let models = require("@database/model")({ Sequelize, sequelize });
facebook({ Op, models });
})
.catch((e) => {
logger(`${e.stack}`, 2);
// console.error(e);
})