{"id":17497,"library":"atma-io-middleware-base","title":"Atma.js IO Middleware Base","description":"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.","status":"abandoned","version":"1.0.51","language":"javascript","source_language":"en","source_url":"https://github.com/tenbits/atma-io-middleware-base","tags":["javascript","typescript"],"install":[{"cmd":"npm install atma-io-middleware-base","lang":"bash","label":"npm"},{"cmd":"yarn add atma-io-middleware-base","lang":"bash","label":"yarn"},{"cmd":"pnpm add atma-io-middleware-base","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the core I/O framework that this middleware abstraction extends. Required for any middleware created with this utility to function.","package":"atma-io","optional":false}],"imports":[{"note":"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.","wrong":"const { create } = require('atma-io-middleware-base');","symbol":"create","correct":"import { create } from 'atma-io-middleware-base';"},{"note":"This package ships TypeScript types, allowing for type-safe definition of middleware configuration objects, including `name`, `process`, and `processAsync` methods.","symbol":"MiddlewareConfig","correct":"import type { MiddlewareConfig } from 'atma-io-middleware-base';"}],"quickstart":{"code":"import { create } from 'atma-io-middleware-base';\nimport { File, type IFileMiddleware } from 'atma-io'; // Peer dependency\n\ninterface MyCustomOptions {\n  prefix?: string;\n}\n\n// Define the middleware configuration\nconst myMiddleware: IFileMiddleware<MyCustomOptions> = create<MyCustomOptions>({\n  name: 'my-super-middleware',\n  // Synchronous processing example\n  process(content, filename, options) {\n    const prefixedContent = options.prefix ? `${options.prefix}: ${content}` : content;\n    console.log(`Processing sync file: ${filename}`);\n    return { content: prefixedContent };\n  },\n  // Asynchronous processing example (recommended for heavy tasks)\n  async processAsync(content, filename, options) {\n    return new Promise((resolve) => {\n      setTimeout(() => {\n        const prefixedContent = options.prefix ? `${options.prefix} (async): ${content}` : content;\n        console.log(`Processing async file: ${filename}`);\n        resolve({ content: prefixedContent });\n      }, 50);\n    });\n  }\n});\n\n// In a real application, you would register this middleware with atma-io\n// For demonstration, we'll just show its structure.\nconsole.log(`Middleware created: ${myMiddleware.name}`);\n\n// Example of how atma-io might use it (conceptual)\nconst mockFileContent = 'Hello, Atma.js!';\nconst mockFilename = 'test.txt';\nconst mockOptions = { prefix: 'DEBUG' };\n\n// Simulate synchronous process call\nconst syncResult = myMiddleware.process?.(mockFileContent, mockFilename, mockOptions);\nconsole.log('Sync Result:', syncResult?.content);\n\n// Simulate asynchronous processAsync call\nmyMiddleware.processAsync?.(mockFileContent, mockFilename, mockOptions)\n  .then(asyncResult => console.log('Async Result:', asyncResult.content));\n","lang":"typescript","description":"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."},"warnings":[{"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.","message":"The 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`.","severity":"breaking","affected_versions":">=1.0.51"},{"fix":"Ensure `atma-io` is installed and meets the peer dependency requirement (npm i atma-io@^1.1.7).","message":"The 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.","severity":"gotcha","affected_versions":"<1.0.51"},{"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.","message":"While 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Install the peer dependency: `npm install atma-io` or `yarn add atma-io`.","cause":"The `atma-io` package is a peer dependency and must be explicitly installed alongside `atma-io-middleware-base`.","error":"Error: Cannot find module 'atma-io' or Missing peer dependency 'atma-io'"},{"fix":"Use a named import: `import { create } from 'atma-io-middleware-base';` or for CommonJS: `const { create } = require('atma-io-middleware-base');`","cause":"This usually indicates an incorrect import statement. The package exports `create` as a named export, not a default export.","error":"TypeError: create is not a function"},{"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.","cause":"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`.","error":"Argument of type '{ name: string; process(...): { content: string; }; }' is not assignable to parameter of type 'IFileMiddleware<any>'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}