-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
47 lines (36 loc) · 1.11 KB
/
app.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
/*
Head File 'Werbetafel Stadtmarketing'-Project
Author: Robin Hart
Creation date: 04.11.22
Github: https://github.com/Muezzin-ay/Werbetafel-Stadtmarketing
*/
const http = require('http');
const express = require('express');
const { Server } = require('socket.io');
// Own
const api = require('./modules/module_api');
const db = require('./modules/db');
const { establishTelegramConnection } = require('./modules/telegram_bot');
// Settings
const PORT = 8084;
//establish database connection
db.authenticate();
//db.initDatabase();
var app = express();
var server = http.createServer(app)
const io = new Server(server);
io.on('connection', (socket) => {
console.log('[SERVER] Socket connection established.');
});
app.use(function(req, res, next){
req.io = io; //Make Socket Stream accessible in api file
next();
});
// Backend connection
app.use('/api', api);
// Frontend
app.use('/', express.static(__dirname + "/public"))
app.use('/show', express.static(__dirname + "/public/show.html"))
establishTelegramConnection(io);
server.listen(PORT);
console.log('[SERVER] Listening on Port ' + PORT);