New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

flambo

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flambo

Lightweight TypeScript decorators for building modular class-based applications

latest
Source
npmnpm
Version
0.1.2
Version published
Weekly downloads
21
-4.55%
Maintainers
1
Weekly downloads
 
Created
Source

Flambo

A lightweight TypeScript decorator library for building modular class-based applications. Flambo provides utility decorators that reduce boilerplate code while maintaining clean architecture principles.

Installation

npm install flambo
yarn add flambo

Features

  • 🪶 Lightweight with zero dependencies
  • 🎯 TypeScript-first approach
  • 🧩 Modular - use only what you need
  • 🔒 Type-safe environment variables handling
  • 📦 Property memoization
  • 📝 Metadata collection utilities

Decorators

@Once

Memoizes getter results after the first call. Perfect for expensive computations or one-time initializations.

class UserService {
  // Without @Once
  private _config: Config | null = null;
  get config(): Config {
    if (!this._config) {
      this._config = new Config();
    }
    return this._config;
  }

  // With @Once
  @Once()
  get config() {
    return new Config();
  }
}

@Env

Simplifies environment variable handling with type conversion and default values.

class ServerConfig {
  @Env(3000)
  port: number;

  @Env({ type: String, default: 'development' })
  nodeEnv: string;

  @Env({ type: 'json', key: 'DB_CONFIG' })
  dbConfig: DatabaseConfig;
}

@PushTo

Collects decorated property names into an array. Useful for metadata collection and reflection.

class ValidationRules {
  // Array can be explicitly defined for type safety
  public requiredFields: string[];

  @PushTo('requiredFields')
  username: string;

  @PushTo('requiredFields')
  password: string;

  // Decorator automatically creates: requiredFields = ['username', 'password']
}

Usage Examples

import { Once, Env, PushTo } from 'flambo';

class AppConfig {
  public initTasks: string[];

  @Env({ type: Number, default: 3000 })
  port: number;

  @Once()
  get databaseUrl(): string {
    return this.buildDatabaseUrl();
  }

  @PushTo('initTasks')
  async connectDatabase() {
    // ...
  }
}

Why Flambo?

Flambo provides lightweight decorators that enhance your classes without enforcing a specific architecture. This makes it perfect for:

  • Building modular services
  • Handling configuration
  • Creating pure class-based containers
  • Reducing boilerplate code
  • Getting rid of DI frameworks
  • Gradual refactoring without rewriting the whole codebase

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Keywords

typescript

FAQs

Package last updated on 13 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts