I’m trying to start a server from my course but when I use node .server.js
nothing happens though I should get console info and see some basic page in the browser at localhost.
server.js
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const flash = require('connect-flash');
const session = require('express-session');
const routes = require('./routes/index');
const app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(session({
secret: "tajnehaslo",
resave: false,
saveUninitialized: true,
cookie: {}
}));
app.use(flash());
app.use('/', routes);
module.exports = app;
app.js
const app = require("./app");
app.set("port", process.env.PORT || 8080);
const server = app.listen(app.get("port"), () => {
console.log(`Listening on ${server.address().port}`);
});
index.js
const express = require('express');
const router = express.Router();
const PagesController = require('../controllers/PagesControler');
const ApplicationsController = require('../controllers/ApplicationsController');
router.get('/', PagesController.home);
router.post('/applications', ApplicationsController.store);
router.get('/index', (req, res) => {
res.render('login');
});
module.exports = router;
I have express installed