Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
angular-universal-express-firebase
Advanced tools
Run Angular Universal on Cloud Functions and Firebase Hosting
A packaged Cloud Function to serve Angular Universal apps.
npm i angular-universal-express-firebase
NB: Run this command afer initialzing functions and from within the functions
folder
const angularUniversal = require('angular-universal-express-firebase');
exports.trigger = angularUniversal.trigger({
index: 'path/to/index.html',
main: 'path/to/bundle.longhash',
enableProdMode: true,
cdnCacheExpiry: 600,
browserCacheExpiry: 300,
staleWhileRevalidate: 120
});
import * as angularUniversal from 'angular-universal-express-firebase';
export let trigger = angularUniversal.trigger({
index: 'path/to/index.html',
main: 'path/to/bundle.longhash',
enableProdMode: true,
cdnCacheExpiry: 600,
browserCacheExpiry: 300,
staleWhileRevalidate: 120
});
There are two parts to an Angular Universal app: the server build and the server.
The current RC version of the Angular CLI covers the server build. Follow these steps to setup the CLI to get a server build.
You may want to use the --output-hashing none
flag with your universal build to avoid needing to change the hash
with each build in your function.js. At this point you should have two app entries in your angularcli.json
file: browser and server. The browser build writes to the dist
folder and the server build writes to the
dist-server
folder.
dist/index.html
.This index file is uneeded because Angular Universal uses the assets in dist-server
to generate the initial HTML.
# npm
npm i firebase-tools -g
# yarn
yarn add firebase-tools --global
firebase init hosting
# specify the public directory to dist
firebase init functions
# this will create a functions folder
# with and index.js, package.json, and set
# of node_modules
functions/index.js
and add the following code.const angularUniversal = require('angular-universal-express-firebase');
exports.trigger = angularUniversal.trigger({
index: __dirname + 'dist-server/index.html',
// make sure this points at the correct hash, or use the --output-hashing none flag on your ng build.
main: __dirname + '/bundle.<generated-hash>',
enableProdMode: true,
cdnCacheExpiry: 600, // cache in the CDN for 10 minutes
browserCacheExpiry: 300, // cache in the browser for 5 minutes
staleWhileRevalidate: 120 // serve a stale version for 2 minutes after cdnCacheExpiry, but refresh CDN in background
});
firebase.json
Firebase Hosting needs to know which Cloud Function to call.
{
"hosting": {
"rewrites": [
{
"source": "**",
"function": "trigger"
}
]
}
}
The Firebase CLI allows you to serve locally and emulate the production environment.
firebase serve --only functions,hosting
# visit locahost:5000
Now that it looks great locally, deploy to production.
firebase deploy
firebase open hosting:site
# automatically opens default browser to the prod site
FAQs
Run Angular Universal on Cloud Functions and Firebase Hosting
The npm package angular-universal-express-firebase receives a total of 0 weekly downloads. As such, angular-universal-express-firebase popularity was classified as not popular.
We found that angular-universal-express-firebase demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.