Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
backend
frontend
pages
.babelrc
.eslintrc
.gitignore
LICENSE
README.md
package.json
webpack.config.js

README.md

frontexpress-demo

Smallest project for starting using frontexpress framework.

image

Quick Start

Clone the git repository:

$ git clone git@github.com:camelaissani/frontexpress-demo.git
$ cd frontexpress-demo

Install dependencies:

$ npm install

Start the server:

$ npm start

Objective

Create a Single Page Application (SPA) in which the routing is managed by frontexpress.

We created a frontexpress application:

// Frontend application
const app = frontexpress();

This application listens two kind of routes:

// api routes (ajax requests)
app.use(apiRouter);

// page routes (complete page refresh)
app.use(pageRouter);

It pops up a dialog to ask sign in when the HTTP error 401 is received

// React on http 401 (Unauthorized need to sign in to access)
app.use((req, res, next)  => {
    if (res.status === 401) {
        window.alert('Your are not authenticated!\n\nPlease sign in.');
        app.httpGet(`/api/login?ori_req=${encodeURIComponent(req.uri)}`);
    } else {
        next();
    }
});

The menu selection is managed through out routes

// On update content select the corresponding menu
router.get((req, res, next) => {
    menu.selection(req.uri);
    next();
});

For more look at the sources.

You can’t perform that action at this time.