Fallos de rutas solucionados

This commit is contained in:
Juan Ferrer Toribio 2016-11-09 13:10:56 +01:00
parent daf556d490
commit 86001a1e8e
5 changed files with 8 additions and 17 deletions

View File

@ -3,7 +3,5 @@ module.exports = function(app) {
User.create ({ User.create ({
email: 'admin@admin.com', email: 'admin@admin.com',
password: '1234' password: '1234'
}, function (err, user) { }, function (err, user) {});
console.log ('User created!');
});
}; };

View File

@ -14,7 +14,7 @@
</div> </div>
<script <script
type="text/javascript" type="text/javascript"
src="/salix/config.js"> src="/static/salix.routes.js">
</script> </script>
<script <script
type="text/javascript" type="text/javascript"

View File

@ -4,19 +4,15 @@ module.exports = function (app) {
var url_account = app.get('url account'); var url_account = app.get('url account');
app.get('/', function (req, res) { app.get('/', function (req, res) {
if (req.cookies['salix-session']) { if (req.cookies['salix-session']) {
res.render('index.ejs'); res.render('index.ejs');
} }
else { else {
res.redirect(url_account + "/?api_key=" + api_key); res.redirect(url_account + "/?api_key=" + api_key);
} }
}); });
//https://github.com/expressjs/cookie-parser
app.get('/login', function (req, res) {
app.get('/login', function (req, res) {
var token = req.query.access_token; var token = req.query.access_token;
if (token) { if (token) {
res.cookie('salix-session', token, { httpOnly: true, path: '/salix' }); res.cookie('salix-session', token, { httpOnly: true, path: '/salix' });
@ -28,17 +24,14 @@ module.exports = function (app) {
}); });
app.get('/config.js', (req, res) => { app.get('/config.js', (req, res) => {
if (req.cookies['salix-session']) { if (req.cookies['salix-session']) {
res.set('Content-Type', 'application/javascript');
// TODO: construir js dinamico de las rutas // TODO: construir js dinamico de las rutas
res.set('Content-Type', 'application/javascript');
res.send('var routesSalix={}'); res.send('var routes = {}');
} }
else { else {
res.status(401); res.status(401);
res.send("No autorizado"); res.send("No autorizado");
} }
}); });
}; };

View File

@ -17,7 +17,7 @@ gulp.task ('routes', function ()
.pipe (concat ('salix.routes.js', {newLine: ','})) .pipe (concat ('salix.routes.js', {newLine: ','}))
.pipe (wrap (globalTpl)) .pipe (wrap (globalTpl))
.pipe (babel ({presets: ['es2015']})) .pipe (babel ({presets: ['es2015']}))
.pipe (gulp.dest ('./build/private')); .pipe (gulp.dest ('./build/public'));
}); });
// Spliting // Spliting

View File

@ -10,7 +10,7 @@ module.exports =
output: { output: {
path: path.join (__dirname, 'build', 'public'), path: path.join (__dirname, 'build', 'public'),
filename: '[name].js', filename: '[name].js',
publicPath: 'build/public/', publicPath: '/static/',
chunkFilename: "[name].js" chunkFilename: "[name].js"
}, },
module: { module: {