-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
86 lines (66 loc) · 2.16 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
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
77
78
79
80
81
82
83
84
85
86
var expressSession = require('express-session'),
initPassport = require('./app_server/passport/init');
const express = require('express'),
http1_port = 80,
path = require('path'),
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
app = express(),
db = require('./app_server/models/db'),
//rfid = require('./app_server/rfid/rfid'),
routerManager = require('./app_server/routes/routerManager'),
flash = require('connect-flash'),
passport = require('passport'),
ejsLayout = require('express-ejs-layouts'),
serialPort = require('./app_server/serialport/comm').serialPort;
/*----------------------------------------------*/
/*var Gpio = require('rpio');
const OUTPUT = Gpio.OUTPUT;
const INPUT = Gpio.INPUT;
const HIGH = Gpio.HIGH;
const LOW = Gpio.LOW;
var pinMode = (pin, mode) => { Gpio.open(pin, mode, LOW); }
var digitalWrite = (pin, value) => { Gpio.write(pin, value); }
const motoren = 15;
const motor1 = 3;
const motor2 = 5;
const buzzerPin = 10;
pinMode(motor1, OUTPUT);
pinMode(motor2, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(motoren, OUTPUT);
digitalWrite(motor1, HIGH);
digitalWrite(motor2, LOW);*/
app.set('view engine', 'ejs')
app.set('views', path.join(__dirname, '/app_server/views'))
app.use(ejsLayout)
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: 'false' }))
app.use(cookieParser())
app.use('/public', express.static(path.join(__dirname, 'public')))
app.use(expressSession({
secret: 'mySecretKey',
resave: false,
saveUninitialized: true,
}))
app.use(passport.initialize())
app.use(passport.session())
app.use(flash())
initPassport(passport)
routerManager(app)
app.listen(http1_port, () => {
startupKey = Buffer.from([0x43, 0x34]);
serialPort.write(startupKey, err => {
if (err) {
return console.log('Error on write: ', err.message)
}
console.log('message written')
})
console.log('Listening http server on port: ' + http1_port)
});
process.on('SIGINT', function () {
console.log("\nCaught interrupt signal");
//digitalWrite(motor1, LOW);
//digitalWrite(motor2, LOW);
process.exit();
});