Angular 4 the new gig

Andrea Dessì
Nov 15, 2017 · 5 min read
Image for post
Image for post
Onefootball office

Project Setup: Welcome Typescript / Webpack / NPM Script

Universal Code and isomorphic rendering

Routes

$stateProvider
.state('competition', {
url: '/:lang/'+ getLocalizedString('URL.COMPETITION'),
...
})
import * as express from 'express';
import { ngExpressEngine } from '@nguniversal/express-engine';

// Set the engine
app.engine('html', ngExpressEngine({
bootstrap: ServerAppModule // Give it a module to bootstrap
}));
app.set('view engine', 'html');

app.get('/**/*', (req: Request, res: Response) => { // render every url with the ServerAppModule
res.render('index', {
req,
res
});
});
// Set the engine
app.engine('html', ngExpressEngine({
bootstrap: ServerAppModule // Give it a module to bootstrap
}));
app.set('view engine', 'html');

// Use the routing config
const ROUTES = JSON.parse(fs.readFileSync(`markets-routing.json`, 'utf8')); // assuming this ['en', 'de', 'fr', 'es', 'it'];
ROUTES.forEach((route) => {
app.get(`/${route}`, angularHandler);
app.get(`/${route}/*`, angularHandler);
});

It works though

OneFootball Tech Blog

Words from the OneFootball Product, Data and Engineering…

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store