-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
77 lines (71 loc) · 1.99 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'use strict';
var express = require('express'),
app = express(),
server = require('http').Server(app),
bodyParser = require('body-parser'),
clc = require('cli-color'),
db = require('./lib/modules/DB'),
socket = require('./lib/modules/eventsSocket');
var tokenLeads = 'a2a43051c137da3cfc698f80b10176b0'; //токен Leads.su
/* глабальные переменные */
var SettingServer = {};
SettingServer.Adedress = '127.0.0.1';
SettingServer.Port = 80;
/* ---------- */
app.set('view engine', 'pug'); //подключение шаблонизатора
app.use('/public', express.static('public'));
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({extended: true})); // support encoded bodies
/* главная страница */
app.get('/', async (req, rs) => {
let all_product;
await db.Get_All_Product().then(res => {
all_product = res;
});
let all_category;
await db.get_all_category().then(res => {
all_category = res;
})
let all_periods;
await db.get_all_periods().then(res => {
all_periods =res
})
let all_cpa;
await db.get_all_cpa().then(res => {
all_cpa = res;
})
let all_organization;
await db.get_all_organization().then(res => {
all_organization = res;
})
let all_docs;
await db.get_all_dosc().then(res => {
all_docs = res;
})
let all_money;
await db.get_all_get_money().then(res => {
all_money = res;
})
rs.render('index', {
all_product: all_product,
all_category: all_category,
all_periods: all_periods,
all_cpa: all_cpa,
all_organization: all_organization,
all_docs: all_docs,
all_money: all_money
});
});
try {
server.listen(SettingServer.Port, SettingServer.Adedress, () => {
console.log(
clc.yellow(
'Сервер запущен по адресу',
'http://' + SettingServer.Adedress + ':' + SettingServer.Port,
),
);
socket.Events(server);
});
} catch (err) {
console.log(clc.red('Произошла ошибка:', err.message));
}