V
V
Valeriy Donika2015-10-16 23:49:19
Node.js
Valeriy Donika, 2015-10-16 23:49:19

How to create admin layout in MEAN correctly?

Hello. In general, there is MEAN which I myself do from scratch using passport. I understood how to register an eccentric, log in and save in cookies.
I can’t understand how I can create a separate layout for the admin panel where there will be another index.html
In express there is a public folder, I created the admin folder in it and pushed another index.html there, created the adminApp module, etc.
In the frontend, when logging in, if express sees that the guy has the admin role in the database, then it returns state === 'toadmin' and then sends it to the admin / enter route, in which, in turn, this code

var path = require('path');
var express = require('express');
var router = express.Router();

module.exports = function(){
   router.get('/enter', function(req, res){
        res.sendfile('../admin/index.html');
    });

   return router;

};

As a result, I want Express to return me another file in which there will already be a different module, a different layout, controllers, etc. but at first I get nothing and then 504 .... How to do this? :)
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2015-10-17
@k12th

In express there is a public folder in it created a folder admin

Eee, why? Usually they make a view folder and put templates in it. And they call res.render, not res.sendFile. Perhaps this is related to "I get nothing at first and then 504".
And so everything is correct, we make the admin subfolder, put our index.jade, layout.jade there and whatever our heart desires, and in the corresponding routes in the middleware we check if the dude has rights.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question