Registry / web-framework / atma-io-middleware-base

atma-io-middleware-base

JSON →
library1.0.51jsnpmunverified

This package, `atma-io-middleware-base` (current stable version 1.0.51), serves as a foundational utility for abstracting and creating custom middleware extensions for the `atma-io` library. It simplifies the process of integrating custom file processing logic—such as reading, compiling, or preprocessing files—into the `atma-io` ecosystem. Developers use it to define synchronous `process` or asynchronous `processAsync` methods that transform file content, returning an object with the modified content and an optional source map. Its configuration can be extended via `package.json` under the specific middleware's name. As part of the Atma.js Project, this package's development appears to be inactive, with the last known activity dating back to 2017, suggesting an abandoned or unmaintained status.

npm install atma-io-middleware-base
INSTALL
IMPORT
SIG · ATMA-IO-MIDDLEWARE
A
atma-io-middleware-base
web-frameworkjavascriptv1.0.51
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.

create
import { create } from 'atma-io-middleware-base';
const { create } = require('atma-io-middleware-base');
While the README shows CommonJS `require`, modern Node.js and TypeScript projects should use ESM `import`. This package primarily provided CJS exports based on its last update in 2017.
MiddlewareConfig
import type { MiddlewareConfig } from 'atma-io-middleware-base';
This package ships TypeScript types, allowing for type-safe definition of middleware configuration objects, including `name`, `process`, and `processAsync` methods.

This quickstart demonstrates how to create a custom `atma-io` file middleware using `create`, defining both synchronous and asynchronous `process` methods, and showing its basic structure and conceptual usage.

import { create } from 'atma-io-middleware-base'; import { File, type IFileMiddleware } from 'atma-io'; // Peer dependency interface MyCustomOptions { prefix?: string; } // Define the middleware configuration const myMiddleware: IFileMiddleware<MyCustomOptions> = create<MyCustomOptions>({ name: 'my-super-middleware', // Synchronous processing example process(content, filename, options) { const prefixedContent = options.prefix ? `${options.prefix}: ${content}` : content; console.log(`Processing sync file: ${filename}`); return { content: prefixedContent }; }, // Asynchronous processing example (recommended for heavy tasks) async processAsync(content, filename, options) { return new Promise((resolve) => { setTimeout(() => { const prefixedContent = options.prefix ? `${options.prefix} (async): ${content}` : content; console.log(`Processing async file: ${filename}`); resolve({ content: prefixedContent }); }, 50); }); } }); // In a real application, you would register this middleware with atma-io // For demonstration, we'll just show its structure. console.log(`Middleware created: ${myMiddleware.name}`); // Example of how atma-io might use it (conceptual) const mockFileContent = 'Hello, Atma.js!'; const mockFilename = 'test.txt'; const mockOptions = { prefix: 'DEBUG' }; // Simulate synchronous process call const syncResult = myMiddleware.process?.(mockFileContent, mockFilename, mockOptions); console.log('Sync Result:', syncResult?.content); // Simulate asynchronous processAsync call myMiddleware.processAsync?.(mockFileContent, mockFilename, mockOptions) .then(asyncResult => console.log('Async Result:', asyncResult.content));
Debug
Known issues
breakingThe package `atma-io-middleware-base` appears to be abandoned, with no significant updates or commits since 2017. This implies potential compatibility issues with newer Node.js versions, updated TypeScript features, or recent versions of its peer dependency `atma-io`.
fix
Consider migrating to actively maintained alternatives if available within the Atma.js ecosystem, or fork the repository to apply necessary updates and security patches.
affects: >=1.0.51
gotchaThe package's primary export method `create` is designed for use with `atma-io` version `>=1.1.7`. Using older versions of `atma-io` may lead to unexpected behavior, missing features, or runtime errors as the API contracts might have evolved.
fix
Ensure `atma-io` is installed and meets the peer dependency requirement (npm i atma-io@^1.1.7).
affects: <1.0.51
gotchaWhile the package ships TypeScript types, its age (last updated 2017) means the types might not fully align with modern TypeScript strictness or newer language features. Manual type assertions or stricter linting might be required.
fix
Review generated types for compatibility with your project's TypeScript configuration and consider adding custom declaration files (`.d.ts`) if necessary for stricter typing or newer features.
affects: >=1.0.0
gotchaThe README and examples primarily demonstrate CommonJS `require()`. In modern Node.js environments configured for ESM, attempting to `require()` this package directly might result in `ERR_REQUIRE_ESM` or `create is not a function` errors if the package is not transpiled or handled correctly.
fix
Prefer `import { create } from 'atma-io-middleware-base';` in ESM projects. If using CJS in an ESM-dominant project, ensure proper interoperability or transpilation. For older Node.js versions, `const { create } = require('atma-io-middleware-base');` is correct.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'atma-io' or Missing peer dependency 'atma-io'
The `atma-io` package is a peer dependency and must be explicitly installed alongside `atma-io-middleware-base`.
fix
Install the peer dependency: `npm install atma-io` or `yarn add atma-io`.
TypeError: create is not a function
This usually indicates an incorrect import statement. The package exports `create` as a named export, not a default export.
fix
Use a named import: `import { create } from 'atma-io-middleware-base';` or for CommonJS: `const { create } = require('atma-io-middleware-base');`
Argument of type '{ name: string; process(...): { content: string; }; }' is not assignable to parameter of type 'IFileMiddleware<any>'
This TypeScript error often occurs when the `process` or `processAsync` method's return type or parameters don't exactly match the `IFileMiddleware` interface expected by `create`.
fix
Ensure that `process` and `processAsync` methods return an object with at least a `content: string` property, and optionally `sourceMap: string`. Also, correctly type your `options` generic parameter if used.
Upgrade
Version history
1.0.51latest on npm
Audit
Dependencies
atma-iorequiredProvides the core I/O framework that this middleware abstraction extends. Required for any middleware created with this utility to function.
Agent activity
18 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources