Registry / web-framework / metal-aop

metal-aop

JSON →
library3.0.0jsnpmunverified

metal-aop is a utility package that provides Aspect-Oriented Programming (AOP) capabilities specifically for applications built with the Metal.js framework. AOP allows developers to modularize cross-cutting concerns such as logging, security, and transaction management, by defining advice (code to be executed) and applying it at specific join points (execution points) in the application's flow. The package's latest stable version is 3.0.0, released approximately eight years ago. However, the underlying Metal.js framework has been officially deprecated by Liferay, its primary maintainer, with no active staffing for open-source support and no future plans to use the framework. Consequently, metal-aop is effectively an abandoned project, meaning it receives no new features, bug fixes, or security patches. Its differentiators were primarily its tight integration with Metal.js's component model, which is no longer actively developed.

npm install metal-aop
INSTALL
IMPORT
SIG · METAL-AOP
M
metal-aop
web-frameworkjavascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Aop
const Aop = require('metal-aop');
import { Aop } from 'metal-aop';
Given the package's age (last published ~8 years ago) and Node.js engine requirement (>=0.12.0), CommonJS `require` is the primary and most compatible import mechanism. ESM `import` syntax is unlikely to be supported without a transpiler or later version.
Aspect
const { Aspect } = require('metal-aop');
import Aspect from 'metal-aop';
If specific AOP constructs like an 'Aspect' factory or class were exposed, they would likely be named exports via CommonJS `require` destructuring, consistent with the package's publication era.
before
const { before } = require('metal-aop/src/aop'); // Example for a specific advice type
import { before } from 'metal-aop';
Specific advice types (like 'before', 'after', 'around') might have been exposed as individual functions or part of a main 'Aop' object. Direct import from internal paths (`src/aop`) would be a common CJS pattern for older libraries exposing smaller utilities.

This quickstart demonstrates how to apply 'before', 'after', and 'around' advice to methods of a class using metal-aop, illustrating basic Aspect-Oriented Programming (AOP) concepts like interception.

const Aop = require('metal-aop'); class MyService { doSomething(data) { console.log(`Processing data: ${data}`); return `Result for ${data}`; } anotherMethod() { console.log('Another method called.'); } } const myServiceInstance = new MyService(); // Define a 'before' advice Aop.before(myServiceInstance, 'doSomething', function(originalArgs) { console.log(`[AOP-Before] Preparing to call doSomething with: ${originalArgs[0]}`); }); // Define an 'after' advice Aop.after(myServiceInstance, 'doSomething', function(originalArgs, result) { console.log(`[AOP-After] doSomething finished. Original args: ${originalArgs[0]}, Result: ${result}`); }); // Define an 'around' advice Aop.around(myServiceInstance, 'anotherMethod', function(originalFn) { console.log('[AOP-Around] Before calling anotherMethod'); const result = originalFn(); // Call the original method console.log('[AOP-Around] After calling anotherMethod'); return result; }); console.log('--- Calling doSomething ---'); myServiceInstance.doSomething('input123'); console.log('\n--- Calling anotherMethod ---'); myServiceInstance.anotherMethod();
Debug
Known issues
breakingThe Metal.js framework, which metal-aop is built upon, has been officially deprecated. This means metal-aop is effectively abandoned and will not receive updates, bug fixes, or security patches. Running this library in modern environments without careful consideration may lead to compatibility issues or unpatched vulnerabilities.
fix
Migrate to a actively maintained AOP solution or a different framework. If continued use is unavoidable, significant testing and custom patching may be required.
affects: >=3.0.0
gotchaCompatibility with modern JavaScript (ESM, async/await, newer Node.js versions) is not guaranteed due to the library's age and abandoned status. Its design predates many modern language features and module systems.
fix
Use a CommonJS environment or a transpilation step that targets older JavaScript versions. Avoid using with module bundlers that heavily rely on ESM unless configured for CJS compatibility.
affects: >=3.0.0
gotchaIntegrating `metal-aop` with other modern frontend libraries or frameworks (e.g., React, Vue, Angular) is highly discouraged. It was designed for the Metal.js ecosystem and may cause unexpected conflicts or performance issues outside of it.
fix
For new projects or integrations, choose AOP solutions that are actively maintained and compatible with your current technology stack.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: Aop.before is not a function
The Aop object was not correctly imported or is not available in the scope, or the `before` method does not exist on the imported object.
fix
Ensure `const Aop = require('metal-aop');` is at the top of your file and that `metal-aop` is correctly installed. Verify the AOP object provides a `before` method as expected.
Cannot read properties of undefined (reading 'doSomething')
The target object passed to an AOP method (e.g., `Aop.before`) is `undefined` or `null`, meaning the aspect is trying to attach to a non-existent object.
fix
Ensure the object you are trying to apply AOP to (e.g., `myServiceInstance`) is properly instantiated and not `null` or `undefined` before calling any `Aop` methods on it.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
metalrequiredThis package is a utility for the Metal.js framework and requires the core 'metal' package or its related components to function, as it extends or interacts with Metal.js's architecture for AOP.
Agent activity
2 hits · last 30 days
node
2
Resources
metal-aop — npm install metal-aop · libregistry