Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Readme
midd-router
, midd-static
req.forward('/new/url')
const middServer = require('midd');
const app = middServer();
app.use(async (req, resp, next)=>{
console.log('1');
await next();
console.log('3');
})
app.use(async (req, resp, next)=>{
try{
let user = await User.queryDb();
resp.end(user.name);
}catch(e){
resp.statusCode = 500;
resp.end(e.message)
}
console.log('2');
})
app.listen(8080)
Create an app server.
Attach middlewares. A middleware is a function like (req, resp, next)=>Promise
.
Same as node server.listen()
function.
Catch uncaught error in middlewares
Forward the request to another url.
Used like http.createServer(app.listerner())
use()
, get()
, post()
etcreq.url
object attributes in req
, like host
, port
You can use app.on('error', cb)
to catch the uncaught error, or try/catch
with async/await
in middlewares
Currently only support express middleware operations, like express.Router
and express.use|all|get|post|...()
app.express.get('/a', (req, resp, next)=>{
console.log(req.url);
next()//no return here
})
app.express.use(require('compression')())
app.express.use(require('body-parser').json())
Checkout the CONTRIBUTING.md if you want to help
Licensed under MIT
Copyright (c) 2017 Tian Jian
FAQs
A light-weight, promise-based, middleware-driven and express-compatible web framework
The npm package midd receives a total of 2 weekly downloads. As such, midd popularity was classified as not popular.
We found that midd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.