Advertisement
Guest User

Untitled

a guest
Mar 28th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. const express = require('express');
  2. const path = require('path');
  3. const morgan = require('morgan');
  4. const mysql = require('mysql');
  5. const myConnection = require('express-myconnection');
  6.  
  7. const app = express();
  8.  
  9. //importing routers
  10. const customerRoutes = require('./routes/customer');
  11.  
  12. //settings (Configuraciones)
  13. app.set('port', process.env.PORT || 3000);
  14. app.set('views', path.join(__dirname, 'views'));
  15. app.set('view engine', 'ejs');
  16.  
  17. //middlewares (Funciones)
  18. app.use(morgan('dev'));
  19. app.use(myConnection(mysql,
  20. {
  21. host:'localhost',
  22. user:'root',
  23. password:'',
  24. port:'3306',
  25. database:'crudnodejsmysql'
  26. }, 'single'));
  27. app.use(express.urlencoded({extended: false}));
  28.  
  29.  
  30. //routers (Rutas)
  31. app.use('/', customerRoutes);
  32.  
  33. //statics files
  34. app.use(express.static(path.join(__dirname, 'public')));
  35.  
  36. //starting the server
  37. app.listen(app.get('port'), () => {
  38. console.log(`server on port ${app.get('port')}`);
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement