Express Frappe 🥤 - build express application another way.
[[toc]]
npm install express-frappe
import { ExpressFrappe } from 'express-frappe';
const { server } = new ExpressFrappe({
bodyParser: true,
cors: true,
morgan: true,
middleware: [middleware1, middleware2, middlewareN],
routes: {
'GET /': handler1,
'GET /v1/posts': [authenticate('admin', 'user'), handler2],
'POST /v1/posts': [authenticate('admin'), handler3], // use your imagination!
},
io: {
'/': {
use(io, socket, next) {
// do your middleware stuffs (check auth maybe?)
next();
},
onConnect(io, socket) {
// will called when a socket successfully connected
},
onDisconnect(io, socket) {
// will called when a socket gets disconnected
},
onMessage(io, socket, data: any, cb) {
// `onMessage` here is a custom event
},
},
'/with-namespace': {
use(io, socket, next) {}, // don't forget to call `next()`
onConnect(io, socket) {},
onDisconnect(io, socket) {},
onHelloWithNamespace(io, socket, data, cb) {},
},
},
errorHandler: (err, req, res, next) => {
// handle your shit together!
},
});
server.listen(3000, () => '🚀 Ready to serve!');
MIT