Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chanlito/express-frappe
Express Frappe 🥤- Build express application another way.
https://github.com/chanlito/express-frappe
express expressjs typescript
Last synced: 4 days ago
JSON representation
Express Frappe 🥤- Build express application another way.
- Host: GitHub
- URL: https://github.com/chanlito/express-frappe
- Owner: chanlito
- License: mit
- Created: 2018-06-25T03:58:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-05T04:40:43.000Z (over 6 years ago)
- Last Synced: 2025-02-14T16:02:25.428Z (7 days ago)
- Topics: express, expressjs, typescript
- Language: TypeScript
- Homepage: https://chanlito.github.io/express-frappe
- Size: 610 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Express Frappe
Express Frappe 🥤 - build express application another way.
[](https://github.com/ellerbrock/open-source-badges/)
[](https://github.com/chanlito/express-frappe)
[](https://github.com/chanlito/express-frappe/fork)
[](https://opensource.org/licenses/mit-license.php)
[](https://badge.fury.io/js/express-frappe)
[](https://travis-ci.org/chanlito/express-frappe)
[](https://coveralls.io/github/chanlito/express-frappe?branch=master)
[](https://david-dm.org/chanlito/express-frappe)[[toc]]
## Setup
```bash
npm install express-frappe
```## How to use
```ts
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!');
```## License
MIT