diff --git a/app.js b/app.js deleted file mode 100644 index e69de29..0000000 diff --git a/index.js b/index.js deleted file mode 100644 index e69de29..0000000 diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 0000000..b060f4f --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,45 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] +2 info using npm@3.5.2 +3 info using node@v8.10.0 +4 verbose run-script [ 'prestart', 'start', 'poststart' ] +5 info lifecycle gymbuddy@1.0.0~prestart: gymbuddy@1.0.0 +6 silly lifecycle gymbuddy@1.0.0~prestart: no script for prestart, continuing +7 info lifecycle gymbuddy@1.0.0~start: gymbuddy@1.0.0 +8 verbose lifecycle gymbuddy@1.0.0~start: unsafe-perm in lifecycle true +9 verbose lifecycle gymbuddy@1.0.0~start: PATH: /usr/share/npm/bin/node-gyp-bin:/home/banna/Documents/GymBuddy/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games +10 verbose lifecycle gymbuddy@1.0.0~start: CWD: /home/banna/Documents/GymBuddy +11 silly lifecycle gymbuddy@1.0.0~start: Args: [ '-c', 'node src/index.js' ] +12 silly lifecycle gymbuddy@1.0.0~start: Returned: code: 1 signal: null +13 info lifecycle gymbuddy@1.0.0~start: Failed to exec start script +14 verbose stack Error: gymbuddy@1.0.0 start: `node src/index.js` +14 verbose stack Exit status 1 +14 verbose stack at EventEmitter. (/usr/share/npm/lib/utils/lifecycle.js:232:16) +14 verbose stack at emitTwo (events.js:126:13) +14 verbose stack at EventEmitter.emit (events.js:214:7) +14 verbose stack at ChildProcess. (/usr/share/npm/lib/utils/spawn.js:24:14) +14 verbose stack at emitTwo (events.js:126:13) +14 verbose stack at ChildProcess.emit (events.js:214:7) +14 verbose stack at maybeClose (internal/child_process.js:925:16) +14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) +15 verbose pkgid gymbuddy@1.0.0 +16 verbose cwd /home/banna/Documents/GymBuddy +17 error Linux 4.15.0-20-generic +18 error argv "/usr/bin/node" "/usr/bin/npm" "start" +19 error node v8.10.0 +20 error npm v3.5.2 +21 error code ELIFECYCLE +22 error gymbuddy@1.0.0 start: `node src/index.js` +22 error Exit status 1 +23 error Failed at the gymbuddy@1.0.0 start script 'node src/index.js'. +23 error Make sure you have the latest version of node.js and npm installed. +23 error If you do, this is most likely a problem with the gymbuddy package, +23 error not with npm itself. +23 error Tell the author that this fails on your system: +23 error node src/index.js +23 error You can get information on how to open an issue for this project with: +23 error npm bugs gymbuddy +23 error Or if that isn't available, you can get their info via: +23 error npm owner ls gymbuddy +23 error There is likely additional logging output above. +24 verbose exit [ 1, true ] diff --git a/package.json b/package.json index a51f7a1..e9c0766 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "description": "", "main": "index.js", "scripts": { + "start" : "node src/index.js", + "go" : "nodemon src/index.js", "test": "jest" }, "repository": { diff --git a/public/404.html b/public/404.html index e69de29..27ed9ef 100644 --- a/public/404.html +++ b/public/404.html @@ -0,0 +1 @@ +

404 page not found

\ No newline at end of file diff --git a/public/500.html b/public/500.html index e69de29..7e85278 100644 --- a/public/500.html +++ b/public/500.html @@ -0,0 +1 @@ +

server error 500

\ No newline at end of file diff --git a/src/app.js b/src/app.js new file mode 100644 index 0000000..3e60e33 --- /dev/null +++ b/src/app.js @@ -0,0 +1,9 @@ +const express = require('express'); +const controllers = require('./controller/index'); + +const app = express(); + +app.set('port', process.env.PORT || 3000); +app.use(controllers); + +module.exports = app; \ No newline at end of file diff --git a/src/controller/error.js b/src/controller/error.js new file mode 100644 index 0000000..858fa58 --- /dev/null +++ b/src/controller/error.js @@ -0,0 +1,14 @@ +const path = require('path'); + +exports.client = (req, res) => { + res + .status(404) + .sendFile(path.join(__dirname, '..', '..', 'public', '404.html')); +}; + +exports.server = (err, req, res, next) => { + console.log(err.message); + res + .status(500) + .sendFile(path.join(__dirname, '..', '..', 'public', '500.html')) +}; \ No newline at end of file diff --git a/src/controller/index.js b/src/controller/index.js index e69de29..895165d 100644 --- a/src/controller/index.js +++ b/src/controller/index.js @@ -0,0 +1,12 @@ +const express = require('express'); +const router = express.Router(); +const error = require('./error'); + +router.get('/', (req, res) => { + res.send('Hello World') +}) + +router.use(error.client); +router.use(error.server); + +module.exports = router; \ No newline at end of file diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..9cdc13c --- /dev/null +++ b/src/index.js @@ -0,0 +1,5 @@ +const app = require('./app'); + +app.listen(app.get('port'), () => { + console.log('app is running on port', app.get('port')); +}) \ No newline at end of file