Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@grlt-hub/app-compose
Advanced tools
Create scalable, module-based applications with ease.
Create scalable, module-based applications with ease.
Modern applications thrive on modular architecture, adapting seamlessly to evolving business needs. To achieve true modularity, though, you need more than just independent components—you need an efficient way to bring them together. This means controlling how modules load, in what order, and with which dependencies. It gets even trickier when you want to turn off parts of the system without any traces in the code, like if/else
statements, and without affecting the stability of other components.
app-compose
is designed to make this seamless. It lets you dynamically enable or disable modules as needed, not only preventing their code from loading when they’re off but also excluding all related dependencies. This means no excess resource use and optimized performance, even as the app grows.
With app-compose
, you can scale your applications effortlessly—whether you’re building a lightweight tool or a complex, feature-rich system. By managing dependency flow and on-demand module loading, app-compose
provides the control you need to build applications that are both flexible and robust.
There are three entities: users, accounts, and wallets.
If the user exists, then the accounts entity should be started. If the accounts entity is done, then the wallets entity should be started.
import { createContainer, compose } from '@grlt-hub/app-compose';
// wrap the module in a container
const user = createContainer({
id: 'user',
start: async () => {
const data = await fetchUser();
return { api: { data } };
},
});
const accounts = createContainer({
id: 'accounts',
dependsOn: [user],
start: async ({ user }) => {
const data = await fetchAccounts({ id: user.data.id });
return { api: { data } };
},
enable: ({ user }) => user.data.id !== null,
});
const wallets = createContainer({
id: 'wallets',
dependsOn: [accounts],
start: () => ({ api: null }),
});
// up the containers
await compose.up([user, wallets, accounts]);
// { user: 'idle', accounts: 'idle', wallets: 'idle' }
// { user: 'pending', accounts: 'idle', wallets: 'idle' }
// { user: 'done', accounts: 'idle', wallets: 'idle' }
//
/* if user.data.id !== null */
/** { user: 'done', accounts: 'pending', wallets: 'idle' } **/
/** { user: 'done', accounts: 'done', wallets: 'pending' } **/
/** { user: 'done', accounts: 'done', wallets: 'done' } **/
//
/* else */
/** { user: 'done', accounts: 'off', wallets: 'off' } **/
//
// compose.up done
The library offers convenient functions for creating and composing modules into a single system. Each module is encapsulated in a container with a clear configuration, including parameters like id, dependsOn, optionalDependsOn, start, and enable. Developers describe containers and launch them using compose.up
fn, without the need to worry about the order of execution. This approach makes working with containers intuitive and close to natural language.
For additional information, guides and api reference visit documentation site.
FAQs
Create scalable, module-based applications with ease.
We found that @grlt-hub/app-compose demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.