npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-coffee-ssr

v1.0.2

Published

NgxCoffeeSsr is a library that provides Server-Side Rendering (SSR) support for Angular applications, with enhanced caching and route management capabilities. It simplifies the setup of SSR for your Angular app, ensuring that your app is rendered on the s

Downloads

6

Readme

NgxCoffeeSsr

NgxCoffeeSsr is a library that provides Server-Side Rendering (SSR) support for Angular applications, with enhanced caching and route management capabilities. It simplifies the setup of SSR for your Angular app, ensuring that your app is rendered on the server for better performance and SEO.

Features

  • Server-Side Rendering (SSR): Easily integrate SSR into your Angular applications.
  • Node Cache Integration: Uses node-cache for in-memory caching with support for background cache refreshing.
  • Customizable Cache Management: Clear cache for specific routes or for the entire application.
  • Dynamic Routes Caching: Cache routes dynamically using a simple configuration.
  • Express Integration: Integrates with Express.js for powerful server-side capabilities.

Installation

To install the NgxCoffeeSsr library, use the following command:

npm install ngx-coffee-ssr

Also checkout the CoffeeSsrCli library:

npm install coffee-ssr-cli

this tool helps you configure your project without writing a single line of code, everytime you see coffee-ssr it is related to coffee-ssr-cli

Usage

Initial Setup

To get started, initialize the SSR server by importing the required modules and running the server, this can be achieve be running the command below:

  coffee-ssr init

will output coffee-ssr.ts file on root directory with:

import { runSsrServer } from 'ngx-coffee-ssr';
import { AppServerModule } from './src/app/app.server.module';

runSsrServer({
  serverModule: AppServerModule,
  disableLogs: false, // Set to true to disable logging
  appName: 'your-app-name', // Optional: Name used for cache key prefix
  refreshTimeInSeconds: 2400 // Optional: Time in seconds to refresh cache (default: 40 minutes)
});

Commands

Run the following commands to manage your SSR setup:

  • Generate Routes: Extracts all routes from Angular routing modules and generates a routes.txt file for caching.

    coffee-ssr generate routes
  • Initialize Project for SSR: Sets up your project for SSR by configuring necessary files and settings.

    coffee-ssr init
  • Clean Up Project: Cleans up your project for SSR compatibility, removing unused imports and adjusting configurations.

    coffee-ssr clean

Cache Management

  • Clear Cache for Specific Routes:

    Send a POST request to /clear-cache with a JSON body specifying the route name to clear the cache for that specific route.

    {
      "name": "your-app-name"
    }
  • Clear All Cache:

    Send a POST request to /clear-cache without any parameters to clear the entire cache.

Customizing Cache Behavior

  • Cache Prefix: Customize the cache prefix globally by setting the appName parameter in runSsrServer.

  • Cache Refresh Interval: Configure the time interval (in seconds) to refresh the cache by setting refreshTimeInSeconds.

Building the Library

Run ng build ngx-coffee-ssr to build the project. The build artifacts will be stored in the dist/ directory.

Running Unit Tests

Run ng test ngx-coffee-ssr to execute the unit tests via Karma.

Publishing the Library

After building your library with ng build ngx-coffee-ssr, go to the dist folder cd dist/ngx-coffee-ssr and run npm publish.

Further Help

To get more help on the Angular CLI use ng help or visit the Angular CLI Overview and Command Reference.

Contributions

Contributions are welcome! Please feel free to submit a pull request or open an issue for any suggestions or bug reports.

Additional Setup

While ngx-coffee-ssr allows you to easily set up SSR for your Angular app, it is highly recommended to use the coffee-ssr-cli tool to accelerate the setup process. This CLI tool provides commands such as init, generate routes, and clean to automatically configure your project.

Make sure to install the coffee-ssr-cli tool:

npm install -g coffee-ssr-cli

Important

To fully leverage the capabilities of ngx-coffee-ssr, ensure that you run coffee-ssr init to generate all necessary boilerplate code and configurations required for SSR.