Skip to content

Commit

Permalink
Merge pull request #44 from FAC-Sixteen/feature/serversetup
Browse files Browse the repository at this point in the history
server setup relates#41
  • Loading branch information
bantek89 authored May 14, 2019
2 parents 0840642 + 97a0b01 commit ee9db59
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 0 deletions.
Empty file removed app.js
Empty file.
Empty file removed index.js
Empty file.
45 changes: 45 additions & 0 deletions npm-debug.log
Original file line number Diff line number Diff line change
@@ -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 [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 silly lifecycle [email protected]~prestart: no script for prestart, continuing
7 info lifecycle [email protected]~start: [email protected]
8 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~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 [email protected]~start: CWD: /home/banna/Documents/GymBuddy
11 silly lifecycle [email protected]~start: Args: [ '-c', 'node src/index.js' ]
12 silly lifecycle [email protected]~start: Returned: code: 1 signal: null
13 info lifecycle [email protected]~start: Failed to exec start script
14 verbose stack Error: [email protected] start: `node src/index.js`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/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.<anonymous> (/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 [email protected]
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 [email protected] start: `node src/index.js`
22 error Exit status 1
23 error Failed at the [email protected] 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 ]
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"start" : "node src/index.js",
"go" : "nodemon src/index.js",
"test": "jest"
},
"repository": {
Expand Down
1 change: 1 addition & 0 deletions public/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>404 page not found </h1>
1 change: 1 addition & 0 deletions public/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>server error 500</h1>
9 changes: 9 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 14 additions & 0 deletions src/controller/error.js
Original file line number Diff line number Diff line change
@@ -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'))
};
12 changes: 12 additions & 0 deletions src/controller/index.js
Original file line number Diff line number Diff line change
@@ -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;
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('app is running on port', app.get('port'));
})

0 comments on commit ee9db59

Please sign in to comment.