-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coreys branch #1
Open
devspacenine
wants to merge
43
commits into
master
Choose a base branch
from
coreys-branch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
6930a4c
Just adding dependencis to packages.json and some common package desc…
devspacenine c59a7db
Just some .gitignore additions that exclude transformed JS and CSS (a…
devspacenine e33741d
Added express setup code for serving static files and a base.html. (A…
devspacenine 5583f02
Added gulpfile with task definitions for building SCSS, transforming …
devspacenine ffa5045
Added entrypoint for client-side JS code that sets up ReactJS with Re…
devspacenine 18818c3
Added a module that configures the Redux store and all of its middleware
devspacenine bd29240
Added the route definitions of the SPA using react-router
devspacenine c5d41fa
Added container components that make up the different route configura…
devspacenine aba60f6
Added a nav bar component that is used in the App container
devspacenine ba97b52
Middleware that helps with debugging/replaying all of a user's actions
devspacenine 5e269d1
Middleware that allows for actions that will store state data in the …
devspacenine 952ff44
Middleware that allows for actions that will make an AJAX request to …
devspacenine 2ef5c95
Actions are methods used by components to announce changes that affec…
devspacenine 1795091
Reducers are methods that receive every action (as an object returned…
devspacenine 378e931
Dockerized the node application and created a linked MySQL container.…
devspacenine a71bd1e
Just some utility methods for working with react and redux
devspacenine d2cbc66
Ignore: left bug in App container component
devspacenine 8a58ed8
Ignore: leftover bugs in container components
devspacenine 36e5c59
Fixed some linting issues
devspacenine 2922938
Made API responses follow similar patterns and always return JSON (He…
devspacenine a93d69e
Moved API routes into their own express.Router
devspacenine a970f89
Clarifying comment
devspacenine 6e9a4c8
Fixed small issue with API redux middleware
devspacenine 67e34de
Ignore: Made players routes more robust and organized
devspacenine bbc7edb
Added redux action dispatchers and constants for the user and player …
devspacenine 592cab0
Added redux action reducers that define how to update the redux state…
devspacenine 07c33e1
Added routes for players and users views
devspacenine 0908dc9
Tweaked routes a little bit
devspacenine ab6b558
Added a dashboard page that will be landed on at the root url
devspacenine d374e1c
Simple pass through component to facilitate deeper path levels in routes
devspacenine f408917
Added users list page and a user profile page
devspacenine f31e25c
Added players list page and a player profile page
devspacenine 464f81d
Renaming some variables and directory names
devspacenine 2a2862b
Added players and users options to the nav
devspacenine fd080cd
Ignore: Couple nav tweaks
devspacenine 0fe6536
Added bootstrap icon fonts
devspacenine d8e1177
API was not returning JSON because of bad header check
devspacenine ffad52e
Making user actions similar to player actions
devspacenine 7a87398
Made the tables more consistent
devspacenine 06d7822
Created the player and user list components, along with event hooks f…
devspacenine 58d6f23
Fixed some issues and fully implemented the users endpoints and actio…
devspacenine 79e718f
Removed example code and cleaned up a little
devspacenine f1d120e
Added more AJAX request verbs to the players and users reducers
devspacenine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
const express = require('express'); | ||
const bodyParser = require('body-parser'); | ||
const data = require('./libs/data'); | ||
const players = require('./libs/data/players'); | ||
const app = express(); | ||
const port = 8080; | ||
'use strict'; | ||
|
||
var express = require('express'), | ||
bodyParser = require('body-parser'), | ||
data = require('./libs/data'), | ||
players = require('./libs/data/players'), | ||
swig = require('swig'), | ||
app = express(), | ||
port = 8080; | ||
|
||
app.use((request, response, next) => { | ||
//console.log(request.headers); | ||
next() | ||
next(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ending every line with a semicolon is also necessary for v8 optimization. Not that it matters for this project, but its a good practice. |
||
}); | ||
|
||
// Body parsing middleware | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({extended: true, limit: '50mb'})); | ||
|
||
app.get('/', (request, response) => { | ||
response.send('Hello from Express!'); | ||
}); | ||
// Swig Templating Setup | ||
app.engine('html', swig.renderFile); | ||
app.set('view engine', 'html'); | ||
app.set('views', __dirname + '/views'); | ||
app.set('view cache', false); | ||
swig.setDefaults({cache: false}); | ||
|
||
// Setup static file server for images, html, css/fonts, and js | ||
app.use('/public', express.static('public')); | ||
|
||
app.get('/users', function(request, response) { | ||
|
||
|
@@ -23,7 +34,7 @@ app.get('/users', function(request, response) { | |
response.send(users); | ||
}) | ||
.catch(function(err) { | ||
console.log(err) | ||
console.log(err); | ||
response.status(500).send(err); | ||
}); | ||
}); | ||
|
@@ -34,11 +45,11 @@ app.post('/users', function(request, response) { | |
console.log(user); | ||
data.createUser(user) | ||
.then(function() { | ||
console.log(arguments) | ||
console.log(arguments); | ||
response.send(`${user.username} created`); | ||
}) | ||
.catch(function(err) { | ||
console.log(err) | ||
console.log(err); | ||
response.status(500).send(err); | ||
}); | ||
}); | ||
|
@@ -67,31 +78,36 @@ app.get('/players', function(request, response) { | |
app.get('/players/:id', function(request, response) { | ||
players.findPlayer(request.params.id) | ||
.then((player) => { | ||
if (player == null) { | ||
if (player === null) { | ||
response.status(404).send(); | ||
} | ||
else { | ||
response.send(player); | ||
} | ||
}) | ||
.catch((err) => response.status(500).send(err)) | ||
.catch((err) => response.status(500).send(err)); | ||
}); | ||
|
||
app.delete('/players/:id', function(request, response) { | ||
players.deletePlayer(request.params.id) | ||
.then(() => response.status(204).send()) | ||
.catch((err) => response.status(500).send(err)) | ||
.catch((err) => response.status(500).send(err)); | ||
}); | ||
|
||
// Default route if no match was found for the url | ||
app.all('/*', function (req, res) { | ||
res.render('base', {}); | ||
}); | ||
|
||
app.use((err, request, response, next) => { | ||
app.use((err, request, response) => { | ||
console.log(err); | ||
response.status(500).send('Something broke!') | ||
response.status(500).send('Something broke!'); | ||
}); | ||
|
||
app.listen(port, (err) => { | ||
if (err) { | ||
return console.log('something bad happened', err) | ||
return console.log('something bad happened', err); | ||
} | ||
|
||
console.log(`server is listening on ${port}`) | ||
console.log(`server is listening on ${port}`); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its a good practice to chain your declarations as long as you can. Something about how v8 does optimization.