-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mjs
21 lines (17 loc) · 901 Bytes
/
index.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import express from 'express';
import cookieParser from 'cookie-parser';
import methodOverride from 'method-override';
import bindRoutes from './routes.mjs';
const app = express(); // Initialise Express instance.
app.set('view engine', 'ejs'); // Set view engine to expect EJS templates.
app.use(express.json()); // Parse request with JSON payloads.
app.use(cookieParser()); // Parse cookies in requests.
app.use(express.urlencoded({ extended: false })); // Parse request bodies for POST requests.
app.use(methodOverride('_method')); // Parse PUT requests sent as POST requests.
app.use(express.static('public')); // Serve files stored in public folder.
app.use(express.static('dist')); // Serve files stored in dist folder.
// Bind route definitions to the Express application.
bindRoutes(app);
// Set Express to listen on the given port.
const PORT = process.env.PORT || 3004;
app.listen(PORT);