-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (26 loc) 路 733 Bytes
/
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
// Initialize
const express = require('express');
const dotenv = require('dotenv');
const app = express();
const cors = require('cors');
dotenv.config();
app.use(express.json());
app.use(cors());
// dependencies
const APIRoutes = require('./routes/apiRoutes');
const HomeController = require('./controllers/homeController');
// Static files
app.use(express.static(__dirname + '/public'));
// configuration
app.set('view engine', 'ejs');
const PORT = process.env.PORT || 3001;
// Routes
app.use('/test', (req, res) => {
res.json({
message: 'Hello World'
});
});
app.use('/api', APIRoutes);
app.get('/', HomeController.index);
// Listen on port 3000
app.listen(PORT, () => console.log(`Listening on ${PORT}`));