This repository was archived by the owner on Oct 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.js
More file actions
45 lines (41 loc) · 1.62 KB
/
Server.js
File metadata and controls
45 lines (41 loc) · 1.62 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
45
require('dotenv').config();
const tweetStream = require('./controller/Stream');
const path = require('path');
const bodyParser = require('body-parser');
const express = require('express');
const notifyRouter = require('./router/LineNotify');
const lineRouter = require('./router/Line');
const apiRouter = require('./router/Api');
const selectRouter = require('./router/SelectSub');
const liffIdRouter = require('./router/Liffid');
const fireDatabase = require('./controller/FirebaseRTD');
const hostPath = process.env.hostpath;
const app = express();
app.use(bodyParser.urlencoded({extended: false}));
(async ()=>{
// getFirebaseData
await fireDatabase.getFirstData();
fireDatabase.startListenFireBase();
// start filter
tweetStream.streamFConnect(0);
})()
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// resource
app.use(`${hostPath||''}/image`, express.static(__dirname + '/public/image'));
app.use(`${hostPath||''}/js`, express.static(__dirname + '/public/js'));
// router
app.use(`${hostPath||''}/line`, lineRouter);
app.use(`${hostPath||''}/notify`, notifyRouter);
app.use(`${hostPath||''}/select`, selectRouter);
app.use(`${hostPath||''}/getLiffId`, liffIdRouter);
app.use(`${hostPath||''}/apis`, apiRouter);
app.get(`${hostPath||''}/`, (req, res) => {
console.log(`method : get / ip : ${req.headers['x-forwarded-for'] || req.connection.remoteAddress}`);
res.status(404).send();
});
// listen port def 3000
const server = app.listen(process.env.PORT || process.env.pport || 3000, () => {
const port = server.address().port;
console.log(`::::: connect port : ${port} :::::`);
});