cap-angular-schematic-ssr
v0.0.7
Published
CAP Schematics SSR with extra features
Downloads
3
Maintainers
Readme
cap-angular-schematic-ssr
This repository is a basic Schematic implementation that add a Interceptor with the Transfer Http Response for SSR request and Cache for Browser requests features.
Prerequisites
- Have an Angular app.
- Have npm 6.13.7 or superior.
- Node 10.6 to the current.
Installation
To run the schematic, execute the following command.
ng add cap-angular-schematic-ssr
Important
- This schematic should be installed after Angular Universal.
Verify in you app.server.module.ts that is
- ServerTransferStateModule imported from '@angular/platform-server';
The Schematic will create a ssr plate scaffold application with the next features:
- Cache Request Interceptor.
Touched files:
app
|-- modules/
|-- cap-ssr/
|-- services/
|-- transfer-state-http-cache.interceptor.ts
|-- cap-ssr-module.ts
What does this Schematic
This Schematic install a Interceptor Service and a Module placed under src/app/modules/cap-ssr and import the module to app.server.ts.
With this Transfer State Http Cache Interceptor is possible to avoid duplicated requests (first on server after on browser) on a SSR aplication and use a Cache feature for avoid repeated request on the browser.
Important
Configure the CanCache Method to only set to Cache specific Urls.
canCache(req: HttpRequest<any>): boolean {
return (req.url.includes('ifthistextispartoftheurl'));
}
}
Usage
angular 8, 9
Built With
Authors
Software Allies - Software Allies
Contributor
César Alonso Magaña Gavilanes - cesaralonso
License
MIT © Software Allies