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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@restheart-cloud/kit-ng

v0.1.9

Published

Angular service, route guards, and HTTP interceptor for RESTHeart Cloud authentication — wraps @restheart-cloud/kit.

Downloads

549

Readme

@restheart-cloud/kit-ng

Wraps @restheart-cloud/kit in an Angular service with signals, route guards, and an HTTP interceptor.

Pairs with RESTHeart Cloud, which gives you a production-ready backend — MongoDB, REST API, authentication, signup/signin, all managed.

Installation

npm install @restheart-cloud/kit-ng @restheart-cloud/kit

Setup

In app.config.ts:

import { provideRhAuth } from '@restheart-cloud/kit-ng';

export const appConfig: ApplicationConfig = {
  providers: [
    provideRhAuth({ apiBaseUrl: environment.apiUrl }),
  ],
};

That one call registers RhAuthService, adds the HTTP interceptor (attaches the Bearer token, clears session on 401), and sets up the DI config.

How sessions work

The kit uses a Bearer token stored in localStorage — no cookies.

  • login() stores the token in localStorage and schedules a proactive refresh at 80% of the token's TTL (~12 minutes for a 15-minute token).
  • Every authenticated request sends Authorization: Bearer <token> automatically.
  • Sessions survive page reloads as long as the token hasn't expired.
  • If the token expires (laptop asleep, tab backgrounded too long, or the user hasn't interacted for 15+ minutes), the next API call gets a 401 and the session is cleared — the user sees "logged out," not a silent failure.

RhAuthService

Inject it anywhere and use signals directly in templates:

@Component({
  template: `
    @if (auth.isAuthenticated()) {
      <span>{{ auth.user()?.profile?.firstName }}</span>
      @if (auth.hasMultipleTeams()) {
        <team-switcher [teams]="auth.teams()" />
      }
    }
  `
})
export class AppComponent {
  auth = inject(RhAuthService);
}

Signals

| Signal | Type | Description | |---|---|---| | user | Signal<UserInfo \| null> | Authenticated user, or null | | isAuthenticated | Signal<boolean> | Derived from user | | teams | Signal<TeamMembership[]> | Teams the user belongs to | | hasMultipleTeams | Signal<boolean> | true when user has more than one team |

Methods

All methods return Observable:

auth.checkSession()                // Observable<UserInfo | null> — reads localStorage, no HTTP if no token
auth.login(email, password)        // Observable<UserInfo>
auth.logout()                      // Observable<void>
auth.register(payload)             // Observable<void>
auth.verify(email, token)          // Observable<void>
auth.invite(email, role)           // Observable<void>
auth.getInvitation(email, token)   // Observable<Invitation>
auth.activate(payload)             // Observable<void>
auth.acceptInvite(token)           // Observable<void>
auth.switchTeam(teamId)            // Observable<void> — re-fetches session
auth.forgotPassword(email)         // Observable<void>
auth.resetPassword(payload)        // Observable<void>

Guards

import { authGuard, publicGuard } from '@restheart-cloud/kit-ng';

export const routes: Routes = [
  {
    path: 'app',
    canActivate: [authGuard],     // redirects to /auth/login if not authenticated
    loadComponent: () => import('./shell/shell.component'),
  },
  {
    path: 'auth/login',
    canActivate: [publicGuard],   // redirects to /app if already authenticated
    loadComponent: () => import('./pages/login/login.component'),
  },
];

authGuard checks the in-memory token first — no HTTP call if the user is already authenticated in the current session.

Quickstart

The fastest path to a working app:

  1. Create a service on RESTHeart Cloud
  2. Fork restheart-cloud-starter-ng
  3. Set apiBaseUrl in environment.ts
  4. ng serve

You get login, signup, email verification, invitations, password reset, and multi-team switching — all wired up.