common-middleware is a JavaScript utility library that provides a collection of reusable middleware functions designed for applications built upon the `base-methods` framework, particularly for projects like Assemble, Verb, Generate, and Update. It currently stands at version 1.0.0, last updated over two years ago, indicating a maintenance phase rather than active development. The library focuses on processing file objects in a pipeline, offering functionalities such as front-matter parsing, escaping and unescaping template delimiters, and managing JSON data on load and pre-write. Its key differentiator is its integration within the `base` and `assemble` ecosystem, providing standardized pre-processing capabilities for file-based templating and content management workflows common in static site generators or documentation builders. It is specifically designed for Node.js environments, historically supporting versions `0.10.0` and above, and primarily uses CommonJS modules.
npm install common-middlewareVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `common-middleware` and register its suite of file processing functions with an `assemble-core` application. Once registered, it automatically handles tasks like front-matter parsing, template escaping, and JSON file processing within the application's file pipeline.
Use `common-middleware` exclusively with applications built on `base-methods` or its derivatives like `assemble-core`.
Always use `const middleware = require('common-middleware');` for consuming this package.Thoroughly test `common-middleware` in your specific target Node.js environment. For critical applications, consider forking the repository for active maintenance or exploring more actively maintained alternatives if available within your ecosystem.
Change `import middleware from 'common-middleware';` to `const middleware = require('common-middleware');`.Ensure that the `app` object you are calling `app.use()` on is an instance of `assemble-core` or a compatible `base-methods` application (e.g., `const app = assemble();`).