-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (29 loc) · 892 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
34
35
36
37
const express = require("express");
const app = express();
const cors = require('cors');
const connection = require('./config/connection');
const router = require('./routes/index');
const path = require('path');
require('dotenv').config();
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
connection.dbConnection();
app.get('/', (req, res) => {
// for send html file as response
res.render('pages/index');
})
app.get('/about', (req, res) => {
const user = {
name: 'jack',
email: '[email protected]',
technologies: ['Angular', 'React', 'Node', 'Laravel']
}
res.render('pages/about', { user });
})
app.use('/api', router);
app.listen(process.env.PORT, () => {
console.log(`server is running on ${process.env.PORT}`);
})