forked from angular-app/angular-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refact(server): move routes into their own library files
- Loading branch information
1 parent
e93b786
commit 3a7e9c5
Showing
6 changed files
with
50 additions
and
30 deletions.
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exports.addRoutes = function (app, config) { | ||
// users | ||
// projects | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
exports.addRoutes = function(app, config) { | ||
// This route deals enables HTML5Mode by forwarding missing files to the index.html | ||
app.all('/*', function(req, res) { | ||
// Just send the index.html for other files to support HTML5Mode | ||
res.sendfile('index.html', { root: config.server.distFolder }); | ||
}); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exports.addRoutes = function (app, config) { | ||
// projects | ||
// scrums | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
exports.addRoutes = function(app, security) { | ||
|
||
app.post('/login', security.login); | ||
app.post('/logout', security.logout); | ||
|
||
// Retrieve the current user | ||
app.get('/current-user', security.sendCurrentUser); | ||
|
||
// Retrieve the current user only if they are authenticated | ||
app.get('/authenticated-user', function(req, res) { | ||
security.authenticationRequired(req, res, function() { security.sendCurrentUser(req, res); }); | ||
}); | ||
|
||
// Retrieve the current user only if they are admin | ||
app.get('/admin-user', function(req, res) { | ||
security.adminRequired(req, res, function() { security.sendCurrentUser(req, res); }); | ||
}); | ||
|
||
}; |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var express = require('express'); | ||
|
||
exports.addRoutes = function(app, config) { | ||
// Serve up the favicon | ||
app.use(express.favicon(config.server.distFolder + '/favicon.ico')); | ||
|
||
// First looks for a static file: index.html, css, images, etc. | ||
app.use(config.server.staticUrl, express.compress()); | ||
app.use(config.server.staticUrl, express.static(config.server.distFolder)); | ||
app.use(config.server.staticUrl, function(req, res, next) { | ||
res.send(404); // If we get here then the request for a static file is invalid | ||
}); | ||
}; |
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