-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
59 lines (48 loc) · 1.7 KB
/
server.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
const express = require('express')
const serveStatic = require('serve-static')
const path = require('path')
const bodyParser = require('body-parser');
const cors=require("cors");
require('dotenv').config()
const app = express()
app.use(bodyParser.json());
app.use(cors());
//AGGIUNGO LE COSE DELL?ALtro sito
const postsRoute = require('./routes/posts');
const missionsRoute = require('./routes/missions');
const manageImagesRoute = require('./routes/manageImages');
const managePowerUpsRoute = require("./routes/managePowerUps");
const manageBadgesRoute = require("./routes/manageBadges");
const manageShopRoute = require("./routes/manageShop");
app.use('/missions', missionsRoute);
app.use('/posts', postsRoute);
app.use('/manageImages', manageImagesRoute)
app.use('/managePowerUps', managePowerUpsRoute);
app.use('/badgesTable', manageBadgesRoute);
app.use('/manageShop', manageShopRoute);
//here we are configuring dist to serve app files
app.use('/', serveStatic(path.join(__dirname, '/dist')))
//ROBA MIA A CASO
var geom_files = path.join(__dirname,'/pbfFiles');
app.use('/pbfFiles',express.static(geom_files));
console.log(geom_files);
//MAGARI VA
//MIO
//app.use(express.static('public'));
app.use(express.static('public'));
app.get('/we', function(req, res) {
res.send('hello world');
});
//ANCORA MA PIù NUOVO
const indexPath = __dirname + '/dist/';
app.get('/', function (req,res) {
res.sendFile(indexPath + "index.html");
});
//FIN QUA
//this * route is to serve project on different page routes except root `/`
app.get(/.*/, function (req, res) {
res.sendFile(path.join(__dirname, '/dist/index.html'))
})
const port = process.env.PORT || 8080
app.listen(port)
console.log(`app is listening on port: ${port}`)