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: 3 months 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: 2024-09-29T12:40:56.445Z (4 months 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.
[![Open Source Love](https://badges.frapsoft.com/os/v3/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
[![Star Repo](http://githubbadges.com/star.svg?user=chanlito&repo=express-frappe&style=flat)](https://github.com/chanlito/express-frappe)
[![Fork Repo](http://githubbadges.com/fork.svg?user=chanlito&repo=express-frappe&style=flat)](https://github.com/chanlito/express-frappe/fork)
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)
[![npm version](https://badge.fury.io/js/express-frappe.svg)](https://badge.fury.io/js/express-frappe)
[![Build Status](https://travis-ci.org/chanlito/express-frappe.svg?branch=master)](https://travis-ci.org/chanlito/express-frappe)
[![Coverage Status](https://coveralls.io/repos/github/chanlito/express-frappe/badge.svg?branch=master)](https://coveralls.io/github/chanlito/express-frappe?branch=master)
[![Dependencies Status](https://david-dm.org/chanlito/express-frappe.svg)](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