-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (29 loc) · 860 Bytes
/
index.js
File metadata and controls
37 lines (29 loc) · 860 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
32
33
34
35
36
37
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const connection = require('./database/database');
const categoriesController = require('./categories/CategoriesController');
const articlesController = require('./articles/ArticlesController');
//view engine
app.set('view engine', 'ejs');
//static files
app.use(express.static('public'));
//body parser
app.use(bodyParser.urlencoded({extend: false}));
app.use(bodyParser.json());
//database
connection
.authenticate()
.then(() => {
console.log('Conexao feita com sucesso');
}).catch((error) => {
console.log(error);
});
app.use("/", categoriesController);
app.use("/", articlesController);
app.get('/', (req, res) => {
res.render('index')
});
app.listen(8080, () => {
console.log('o servidor está rodando!');
});