-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
36 lines (28 loc) · 852 Bytes
/
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
// IMPORTS
const express = require('express');
const bodyParser = require('body-parser');
const frontendRoutes = require('./routes/frontend');
// different routers
const apiRoutes = require('./routes/api');
// VARIABLES
const app = express();
const port = 4400;
// MIDDLEWARE
// for static files
app.use(express.static('public'));
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));
// parse application/json
app.use(bodyParser.json());
app.set('views', './views');
app.set('view engine', 'ejs');
// MIDDLEWARE ROUTES
app.use('/', frontendRoutes);
app.use('/api', apiRoutes);
// homepage
// app.use('/', frontendRouter);
// api
// app.use('/api', apiRouter);
app.listen(port, () => {
console.log(`The server is running on port http://localhost:${port}/`);
});