-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
59 lines (46 loc) · 1.52 KB
/
app.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict'
//tener en cuenta que estan usando una version mas alta de node para utilizar algunas cosas
const express = require('express');
//parser datos para todos los request http
const bodyParser = require('body-parser');
const hbs = require('express-handlebars');
const app = express();
const api = require('./routers');
//middleware
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.engine('.hbs', hbs({
defaultLayout: 'default',
extname: '.hbs'
}));
app.set('view engine', '.hbs');
//revisar porque se usa de esta forma use --> api
app.use('/api', api);
app.use(express.static('public'));// Files css, js etc
app.use(express.static('uploads'));// Files jpg, png etc
app.get('/login', (req, res) => {
res.render('login');
});
app.get('/', (req, res) => {
res.render('product');
});
app.get('/save-product', (req, res) => {
res.render('saveProduct');
});
// app.post('/save-product', upload, function (req, res) {
// console.log('POST /api/product', req.body);
// // req.file is the `avatar` file
// // console.log('Esto es el file -> ', req.file)
// // console.log('Esto es body -> ', req.body)
// upload(req, res, function(err){
// // console.log('Esto es file'+ req.file.destination + req.file.filename);
// if(err){
// return res.status(500).send({ message: 'Error uploading file' });
// }
// res.status(200).send({ file: 'File upload' });
// });
// })
// app.get('/hola', (req, res) =>{
// res.send({ message: 'Hola mundo'})
// })
module.exports = app;