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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@noatgnu/cupcake-core

v1.3.14

Published

A reusable Angular library that provides user management, authentication, and site configuration functionality for cupcake applications.

Downloads

1,198

Readme

Cupcake Core

The cupcake-core library provides essential services, components, and models for building Angular applications that interact with a Cupcake backend. It simplifies authentication, API communication, and provides a set of reusable UI components.

Key Features

  • Authentication: Simplified user authentication and session management.
  • API Service: A robust API service with automatic request/response case transformation.
  • Guards & Interceptors: Route guards and HTTP interceptors for securing your application.
  • Reusable Components: A collection of pre-built components for common UI patterns.
  • Type-safe Models: A comprehensive set of TypeScript interfaces for backend data structures.

Installation

To install the @noatgnu/cupcake-core library, run the following command:

npm install @noatgnu/cupcake-core

Then, import the CupcakeCoreModule into your application's AppModule (or any other feature module):

import { CupcakeCoreModule } from '@noatgnu/cupcake-core';

@NgModule({
  imports: [
    // ... other modules
    CupcakeCoreModule
  ],
  // ...
})
export class AppModule { }

Additionally, you need to provide the CUPCAKE_CORE_CONFIG in your AppModule to configure the API URL:

import { CUPCAKE_CORE_CONFIG } from '@noatgnu/cupcake-core';

@NgModule({
  // ...
  providers: [
    {
      provide: CUPCAKE_CORE_CONFIG,
      useValue: { apiUrl: 'YOUR_API_URL_HERE' }
    }
  ]
})
export class AppModule { }

Services

AuthService

The AuthService handles user authentication, including login, logout, and token management. It uses JWT for authentication and stores tokens in local storage.

Usage:

import { AuthService } from '@noatgnu/cupcake-core';

@Component({ ... })
export class MyComponent {
  constructor(private authService: AuthService) {
    this.authService.isAuthenticated$.subscribe(isAuthenticated => {
      // ...
    });

    this.authService.currentUser$.subscribe(user => {
      // ...
    });
  }

  login() {
    this.authService.login('username', 'password').subscribe(response => {
      // ...
    });
  }

  logout() {
    this.authService.logout().subscribe(() => {
      // ...
    });
  }
}

ApiService

The ApiService is the primary service for communicating with the Cupcake backend. It provides methods for a wide range of functionalities, including user management, site configuration, and more.

Automatic Case Transformation:

The ApiService automatically transforms request data from camelCase (frontend) to snake_case (backend) and response data from snake_case to camelCase. This eliminates the need for manual transformations in your components and services.

Usage:

import { ApiService } from '@noatgnu/cupcake-core';

@Component({ ... })
export class MyComponent {
  constructor(private apiService: ApiService) {
    this.apiService.getUsers().subscribe(response => {
      // `response` is already transformed to camelCase
      console.log(response.results);
    });
  }
}

Guards

The library provides the following route guards:

  • AuthGuard: Ensures that a route can only be accessed by authenticated users.
  • AdminGuard: Ensures that a route can only be accessed by admin users.

Usage (in your routing module):

import { AuthGuard, AdminGuard } from '@noatgnu/cupcake-core';

const routes: Routes = [
  {
    path: 'profile',
    component: UserProfileComponent,
    canActivate: [AuthGuard]
  },
  {
    path: 'admin',
    component: AdminDashboardComponent,
    canActivate: [AdminGuard]
  }
];

Interceptors

The AuthInterceptor automatically attaches the JWT access token to outgoing HTTP requests. It also handles token refreshing when the access token expires.

Components

The cupcake-core library includes a variety of reusable components, such as:

  • Login Form: A complete login form with username/password fields.
  • User Management: Components for listing, creating, and editing users.
  • Color Picker: A color selection component.
  • Toast Notifications: A container for displaying toast messages.
  • Powered-by Footer: A standard footer component.

Models

The library defines a comprehensive set of TypeScript interfaces that correspond to the backend data models. These models provide type safety and autocompletion when working with API responses. Some of the key models include:

  • User
  • SiteConfig
  • Annotation
  • ResourcePermission

By leveraging the services, components, and models provided by cupcake-core, you can significantly accelerate the development of your Angular application and ensure consistency with the Cupcake backend.