Adonis Middleware (Official)

raw JSON →
1.0.14 verified Sat Apr 25 auth: no javascript maintenance

Official collection of middleware for AdonisJS (Adonis Framework), including BodyParser, CORS, Flash, and Shield. Current version 1.0.14, last updated in 2016. This package is part of the legacy AdonisJS 4.x ecosystem and provides HTTP middleware providers for common web security and request parsing tasks. Unlike third-party middleware packages, these are the officially maintained set, tightly integrated with the framework's provider system. Release cadence is low; package is in maintenance mode as AdonisJS moved to a new architecture in v5. Key differentiator: official, framework-specific middleware providers that register automatically via AdonisJS IoC container.

error Error: Cannot find module 'adonis-middleware'
cause Package not installed or wrong import path
fix
npm install adonis-middleware --save
error TypeError: AppMiddlewareProvider is not a constructor
cause Incorrect import style (default vs named)
fix
Use import AppMiddlewareProvider from 'adonis-middleware/providers/AppMiddlewareProvider'
error Error: ENOENT: no such file or directory, open '.../node_modules/adonis-middleware/providers/AppMiddlewareProvider.js'
cause Provider path missing due to version mismatch
fix
Reinstall package: npm install adonis-middleware@1.0.14
deprecated This package is for AdonisJS 4.x only and is not compatible with AdonisJS 5+
fix Use the built-in middleware or AdonisJS v5 official packages
breaking Provider registration path changed in v1.0.0: use 'adonis-middleware/providers/AppMiddlewareProvider'
fix Update provider path in bootstrap/app.js
gotcha The package does not export default; all exports are named
fix Use destructuring: import { Cors } from 'adonis-middleware'
npm install adonis-middleware
yarn add adonis-middleware
pnpm add adonis-middleware

Register AdonisMiddleware providers in the AdonisJS 4.x app bootstrap file.

// bootstrap/app.js
const providers = [
  'adonis-middleware/providers/AppMiddlewareProvider'
]

// Start the server
const { Ioc } = require('adonis-fold')
const app = new (require('adonis-framework/src/App'))()
app.registerProviders(providers)