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

@myrmidon/ngx-tools

v1.0.0

Published

Essential general-purpose tools for Angular apps.

Downloads

578

Readme

NgxTools

This project was generated using Angular CLI version 19.0.0. It originates from NgTools while also renaming it.

My essential, general-purpose tools for Angular applications.

These are the typical services and tools shared by most of my Angular apps. For convenience, I packed them into a single reusable library having no dependencies other than Angular CommonModule.

Using EnvService

The root-injected EnvService service includes a Map with environment settings (name=value pairs, both being strings). These settings get automatically loaded by this service on its initialization, from a specific data member named __env of the global window object, so that you can define all these settings in a separate, unbundled pure JS file.

This file is named env.js under folder public (or src/assets in older apps), included in the scripts of the index.html page of the Angular app. This way you can easily change settings without having to rebuild the app, especially when containerizing it as a Docker image. In this case you can use a volume bind, where the host-specific env.js from local file system replaces the one inside the container, providing all the settings for that specific server environment.

👉 To use this service:

  1. add env.js to your app's public folder.
  2. ensure this script is added to angular.json scripts (env.js under architect/build/options/assets); usually this is already implied by the default glob pattern including all the files in public.
  3. ensure to include env.js in the head of your index.html, BEFORE any other script:
<script src="env.js"></script>

The env.js file should include all your environment-dependent settings, e.g.:

(function (window) {
  window.__env = window.__env || {};
  window.__env.apiUrl = 'http://localhost:60200/api/';
  // ... etc.
}(this));

History

1.0.0

  • 2024-12-19: ⚠️ use singleton for EnvService removing the need for EnvServiceProvider. This is strictly a breaking change, but in the end all what you need to do is just remove EnvServiceProvider from the providers array of your app. The rest of the code will work as before, because the same EnvService will be injected and also properly initialized.

0.0.3

  • first version.