2024-06-23 07:38:56 -05:00
2024-06-23 06:52:10 -05:00
2024-06-23 06:52:10 -05:00
2024-06-23 07:38:49 -05:00
2024-06-23 07:38:49 -05:00
2024-06-23 07:38:49 -05:00
2024-06-23 07:38:56 -05:00
2024-06-23 07:38:56 -05:00
2024-06-23 07:15:33 -05:00
2024-06-23 06:52:10 -05:00
2024-06-23 07:38:49 -05:00

ModiLiteJS

ModiLiteJS is a typescript library for writing modular code with components and dependency injection. It simplifies the development process by allowing you to easily define and manage modules, components, and services, enabling a clean and organized codebase.

Installation

You can install the library using npm:

npm install modilitejs

Usage

Below is a basic example of how to use the library:

Decorators

The library provides three main decorators:

Component

Defines a class as a component.

@Component()
export class MyComponent {
  constructor(private readonly myService: MyService) {
    this.myService.greet();
  }
}

Injectable

Defines a class as an injectable service.

@Injectable()
export class MyService {
  public greet() {
    console.log('Hello, I am a service');
  }
}

Module

Defines a module that can group components, services, and other modules.

@Module({
  components: [MyComponent],
  providers: [MyService],
  imports: [AnotherModule]
})
export class MyModule {}

Libraries

AppFactory

Creates the application instance from a root module.

function bootstrap() {
  AppFactory.create(MyModule).catch((err: Error) => {
    console.error(`[App] Error:`, err.message);
  });
}

bootstrap();

Complete Example

import { Component, Injectable, Module, AppFactory } from 'app-factory';

@Injectable()
export class AppService {
  public greeting() {
    console.log('Hello, I am a service');
  }
}

@Component()
export class AppComponent {
  constructor(private readonly service: AppService) {
    this.service.greeting();
  }
}

@Module({
  components: [
    AppComponent
  ],
  providers: [
    AppService
  ]
})
export class AppModule {}

function bootstrap() {
  AppFactory.create(AppModule).catch((err: Error) => {
    console.error(`[App] Error:`, err.message);
  });
}

bootstrap();

Contributions

Contributions are welcome. Please open an issue or submit a pull request.

License

This library is licensed under the MIT License. You can see more details in the LICENSE file.

Description
ModiLiteJS is a library for writing modular code with components and dependency injection.
Readme MIT 52 KiB
Languages
TypeScript 100%