const express = require('express'); const app = express(); const path = require('path'); const bodyParser= require('body-parser'); const cookieParser = require('cookie-parser'); const routes = require('./routes'); const api = require('./routes/api'); app.set('port', 8080); app.set('views', __dirname + '/views'); app.set('view engine', 'pug'); app.use(express.static(path.join(__dirname, 'public'))); app.use(bodyParser.urlencoded({extended: true})); app.use(bodyParser.json()); app.use(cookieParser()); app.get('/', routes.index); app.get('/:name', routes.partials); app.get('*', (req, res, next) => { res.status(200).send('Eskatu duzun orrialdea ez da aurkitu!'); next(); }); app.post('/',api.login); app.listen(app.get('port'), () => { console.log('Zerbitzaria martxan ' + app.get('port') + ' atakan'); });