-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (23 loc) · 813 Bytes
/
app.js
File metadata and controls
30 lines (23 loc) · 813 Bytes
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
import express from 'express';
import path from 'path';
import {fileURLToPath} from 'url';
import mainRoute from "./routes/mainRoutes.js";
import productsRoutes from "./routes/productsRoutes.js";
import compRoutes from "./routes/compRoutes.js";
const PORT = process.env.PORT || 8080;
const app = express();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// middleware for static files
app.use(express.static(path.join(__dirname, 'public')));
// view settings (EJS)
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
// routes
app.use('/', mainRoute);
app.use('/products', productsRoutes);
app.use('/build', productsRoutes);
app.use('/comp', compRoutes);
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`);
});