
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
@adonisjs/middleware-base
Advanced tools
This repo contains the code to make middleware work with the HTTP and Websocket server. If you are looking for generic middleware library, try co-compose.
const MiddlewareBase = require('@adonisjs/middleware-base')
const middleware = MiddlewareBase('handle')
// register global middleware
middleware.registerGlobal(['App/Middleware/BodyParser'])
await middleware
.getGlobalAndNamed([])
.params([ctx])
.run()
void
Register global middleware
void
Register server type middleware
void
Register an object of named middleware
Runner
Composes server level middleware
Runner
Composes global and named middleware together. Pass empty array when no named middleware are supposed to be executed.
MiddlewareBase class is a simple abstraction written to work just with AdonisJs middleware layer.
Adonis has global, named and server middleware with a slight difference in each. So this class understands all and offers a simple abstraction around them.
Param | Type | Description |
---|---|---|
middlewareFn | String | The function to be called on middleware class |
[warnFn] | function |
void
Register global middleware
Kind: global function
Throws:
InvalidArgumentException
If middleware is not an arrayParam | Type |
---|---|
middleware | Array |
Example
middleware.registerGlobal([
'Adonis/Middleware/BodyParser',
'Adonis/Middleware/Session'
])
void
Register server type middleware
Kind: global function
Throws:
InvalidArgumentException
If middleware is not an arrayParam | Type |
---|---|
middleware | Array |
Example
middleware.use(['Adonis/Middleware/Static'])
void
Register an object of named middleware
Kind: global function
Throws:
InvalidArgumentException
If middleware is not an object with key/value pair.Param | Type |
---|---|
middleware | Object |
Example
middleware.registerNamed({
auth: 'Adonis/Middleware/Auth'
})
Runner
Composes server level middleware
Runner
Composes global and named middleware together. Pass empty array when no named middleware are supposed to be executed.
Kind: global function
Param | Type |
---|---|
namedReference | Array |
FAQs
Middleware base used by Http and Ws server
The npm package @adonisjs/middleware-base receives a total of 3,042 weekly downloads. As such, @adonisjs/middleware-base popularity was classified as popular.
We found that @adonisjs/middleware-base demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.