2.1.0 • Published 7 months ago

@jawis/jab-express v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Utilities for express

Collection of utilities for working with express apps.

Installation

npm i jab-express

Usage

Documentation: Everything is developed in TypeScript, so type declarations are the best place to find information about the individual functions and classes.

Here are some highlights:

WsPoolController

A pool for handling open web socket connections. Note that the pool only will manage clients at the specified url. Clients that connect to another url can be managed by another pool

import express from "express";
import { WsPoolController } from "@jawis/jab-express";

// Create the pool

const wsPool = new WsPoolController(deps);

// Listener for web socket messages.

const onMessage = (msg, nws) => {
  // do something with the `msg` that comes from the web socket: `nws`

  //fx send a message to all clients

  wsPool.send("ping");
};

// Us the pool to make a upgrade handler

const onWsUpgrade = wsPool.makeUpgradeHandler(onMessage);

// Make a router and listen to web socket connections at the url: '/ws'

const router = express.Router();

router.ws("/ws", onWsUpgrade);

Small utilities

  • makeApp
  • makeRoute

Build

All imports are side effect free. So this library is ideal for tree-shaking.

Related work

License

MIT

2.1.0

10 months ago

2.1.0-dev.2

7 months ago

2.1.0-dev.1

7 months ago

2.0.0

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2-dev.1

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.37-dev.2

3 years ago

0.0.37-dev.1

3 years ago

0.0.37-dev

3 years ago

0.0.36

3 years ago

0.0.36-dev

3 years ago

0.0.35

3 years ago

0.0.34

3 years ago

0.0.32

3 years ago

0.0.31

3 years ago

0.0.30

3 years ago

0.0.30-dev.1

3 years ago

0.0.30-dev

3 years ago

0.0.29

3 years ago

0.0.28

3 years ago

0.0.27

3 years ago

0.0.26

3 years ago

0.0.25

3 years ago

0.0.24

3 years ago

0.0.23

3 years ago