-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
31 lines (25 loc) · 743 Bytes
/
app.ts
File metadata and controls
31 lines (25 loc) · 743 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
31
import dotenv from 'dotenv';
import express from 'express';
import expressLayouts from 'express-ejs-layouts';
import morgan from 'morgan';
import { baseUrl, port } from './src/config/constants';
import router from './src/routes/index.route';
// Get all environment variables
dotenv.config();
const app = express();
// Third Party Middlewares
app.use(morgan('dev'));
app.set('views', 'src/views');
app.set('view engine', 'ejs');
app.use(expressLayouts);
// Express Middlewares
app.use(express.static('public'));
app.use(express.static('dist/public'));
// Connect to database
require('./src/config/database');
// Routes
app.use(router);
// Start server
app.listen(port, () => {
console.log(`Portfolio is listening to ${baseUrl}`);
});