@htlkg/core
v0.0.3
Published
Core utilities, types, authentication, and constants for Hotelinking applications.
Readme
@htlkg/core
Core utilities, types, authentication, and constants for Hotelinking applications.
Installation
npm install @htlkg/coreModules
Amplify Astro Adapter
Server-side authentication support for Astro with AWS Amplify. Cookie-based auth context for SSR.
Auth
User authentication functions for server-side and client-side. Cognito integration with role-based access.
Constants
Centralized constants for routes, products, permissions, and user roles.
Errors
Standardized error classes: AppError, AuthError, ValidationError, NotFoundError.
Routes
Type-safe route definitions with parameter interpolation. Eliminates string literals.
Types
Core TypeScript interfaces: Brand, Account, User, Product, ProductInstance.
Utils
Common utilities: logger, formatDate, truncateText, groupBy, debounce, throttle.
Quick Start
// Authentication
import { getUser, hasAccessToBrand } from '@htlkg/core/auth';
// Type-safe routes
import { adminRoutes, buildUrl } from '@htlkg/core/routes';
// Constants
import { PERMISSIONS, USER_ROLES } from '@htlkg/core/constants';
// Error handling
import { NotFoundError, ValidationError } from '@htlkg/core/errors';
// Utilities
import { formatDate, debounce } from '@htlkg/core/utils';