From 48f6785d53a155c4c618fa8dc913696e81c4c28c Mon Sep 17 00:00:00 2001 From: knanahassouna1 Date: Mon, 1 Oct 2018 09:24:19 +0300 Subject: [PATCH 1/2] create file struture --- package.json | 22 ++++++++++++++++++++++ src/controllers/index.js | 0 2 files changed, 22 insertions(+) create mode 100644 package.json create mode 100644 src/controllers/index.js diff --git a/package.json b/package.json new file mode 100644 index 0000000..ceef05c --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "marna-house", + "version": "1.0.0", + "description": "", + "main": "index.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/FACG5/Marna-House.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/FACG5/Marna-House/issues" + }, + "homepage": "https://github.com/FACG5/Marna-House#readme" +} \ No newline at end of file diff --git a/src/controllers/index.js b/src/controllers/index.js new file mode 100644 index 0000000..e69de29 From 77a69a9e144bc8ff3118e2a8f62322837b894ad9 Mon Sep 17 00:00:00 2001 From: knanahassouna1 Date: Mon, 1 Oct 2018 20:55:50 +0300 Subject: [PATCH 2/2] make initial server Relates #16 --- .eslintrc.json | 3 +++ .gitignore | 2 ++ package.json | 22 +++++++++++++++++++--- src/app.js | 26 ++++++++++++++++++++++++++ src/controllers/index.js | 4 ++++ src/index.js | 5 +++++ 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .gitignore create mode 100644 src/app.js create mode 100644 src/index.js diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..6f67564 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "airbnb-base" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..43eacad --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +npm-debug \ No newline at end of file diff --git a/package.json b/package.json index ceef05c..6956386 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "test": "test" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node src/index", + "dev": "nodemon src/index" }, "repository": { "type": "git", @@ -18,5 +20,19 @@ "bugs": { "url": "https://github.com/FACG5/Marna-House/issues" }, - "homepage": "https://github.com/FACG5/Marna-House#readme" -} \ No newline at end of file + "homepage": "https://github.com/FACG5/Marna-House#readme", + "keywords": [], + "devDependencies": { + "eslint": "^5.6.1", + "eslint-config-airbnb-base": "^13.1.0", + "eslint-plugin-import": "^2.14.0", + "istanbul": "^0.4.5", + "nodemon": "^1.18.4", + "tap-spec": "^5.0.0", + "tape": "^4.9.1" + }, + "dependencies": { + "express": "^4.16.3", + "express-handlebars": "^3.0.0" + } +} diff --git a/src/app.js b/src/app.js new file mode 100644 index 0000000..25cf2c1 --- /dev/null +++ b/src/app.js @@ -0,0 +1,26 @@ +const express = require('express'); +const hbs = require('express-handlebars'); +const path = require('path'); +const controller = require('./controllers'); + +const app = express(); + +// Middlewares +app.set('port', process.env.PORT || 3000); +app.disable('x-powered-by'); +app.use(express.json()); +app.use(express.urlencoded()); +app.use(controller); + +// HandleBars +app.set('views', path.join(__dirname, 'views')); +app.set('view engine', 'hbs'); +app.engine('hbs', hbs({ + extname: 'hbs', + partialsDir: path.join(__dirname, 'views', 'partials'), + layoutsDir: path.join(__dirname, 'views', 'layouts'), + defaultLayout: 'main', +})); + + +module.exports = app; diff --git a/src/controllers/index.js b/src/controllers/index.js index e69de29..4820e44 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -0,0 +1,4 @@ +const router = require('express').Router(); + + +module.exports = router; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..78ab7b6 --- /dev/null +++ b/src/index.js @@ -0,0 +1,5 @@ +const app = require('./app'); + +app.listen(app.get('port'), () => { + console.log(`The Server is Running on Port ${app.get('port')}`); +});