Skip to content

Commit

Permalink
build server and use app middilware
Browse files Browse the repository at this point in the history
  • Loading branch information
ismail2009 committed Jan 15, 2018
1 parent 73985e3 commit befdacd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const express = require('express');
const app = express();

const hbars = require('express-handlebars');

const path = require('path');
const routes = require('./controllers');

const favicon = require('serve-favicon');
const bodyparser = require('body-parser');

app.use(bodyparser.json());
app.use(bodyparser.urlencoded({ extended: false }));

app.use(express.static(path.join(__dirname,'..','public')));
app.set('views', path.join(__dirname,'views'));
app.set('view engine','hbs');
app.engine('hbs',hbars({
extname:'hbs',
layoutsDir:path.join(__dirname, 'views','layouts'),
partialsDir:path.join(__dirname, 'views', 'partials'),
defaultLayout:'main',
}));

app.set('port',process.env.PORT || 4000);
// app.use(favicon(path.join(__dirname, '..', 'public','img',)));
app.use(routes);


module.exports = app;
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const app = require('./app');

app.listen(app.get('port'),() => {
console.log(`the server work on port ${app.get('port')}`);
})

0 comments on commit befdacd

Please sign in to comment.