Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const path = require('path');
- const morgan = require('morgan');
- const mysql = require('mysql');
- const myConnection = require('express-myconnection');
- const app = express();
- //importing routers
- const customerRoutes = require('./routes/customer');
- //settings (Configuraciones)
- app.set('port', process.env.PORT || 3000);
- app.set('views', path.join(__dirname, 'views'));
- app.set('view engine', 'ejs');
- //middlewares (Funciones)
- app.use(morgan('dev'));
- app.use(myConnection(mysql,
- {
- host:'localhost',
- user:'root',
- password:'',
- port:'3306',
- database:'crudnodejsmysql'
- }, 'single'));
- app.use(express.urlencoded({extended: false}));
- //routers (Rutas)
- app.use('/', customerRoutes);
- //statics files
- app.use(express.static(path.join(__dirname, 'public')));
- //starting the server
- app.listen(app.get('port'), () => {
- console.log(`server on port ${app.get('port')}`);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement