Shared resources

Many of our micro apps will use the same static assets in order not to replicate these resources across apps. We can create a micro app that will serve all the shared resources.

Instead of having a main public folder, each micro app that wants to serve static files can have a separate public folder. This means that we can move all of our shared static resources, and move them to the inner public folder.

We will have the following folder structure:

apps/
-- shared/
---- public
------ assets/
---- index.js

The index.js file will have the following content:

'use strict'; const path = require('path'); const serveStatic = require('serve-static'); class Shared { constructor(config, core, app) { this.app = app; this.root = app.get('root'); ...

Get MEAN Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.