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 ({
email: 'admin@admin.com',
password: '1234'
}, function (err, user) {
console.log ('User created!');
});
};
}, function (err, user) {});
};

View File

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

View File

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

View File

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

View File

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